Skip to content

Commit 3c05e0c

Browse files
authored
Merge pull request #16 from makeclean/windows_line_endings
This fixes and adds tests for the functionality for reading windows files
2 parents db7f31b + 207603f commit 3c05e0c

5 files changed

Lines changed: 41 additions & 2 deletions

File tree

python/Input.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,16 @@ def find_cell(self, cell_id):
3838
return cell
3939
return None
4040

41-
41+
# read the whole file into a big list for further
42+
# procesing
4243
def read(self):
43-
with open(self.filename, 'r', errors="replace") as f:
44+
with open(self.filename, 'rU', errors="replace") as f:
4445
self.file_lines = f.readlines()
4546

4647
# sometimes truely monstrous people stuff weird
4748
# characters into textfiles
4849
self.file_lines = [x.lower() for x in self.file_lines]
50+
4951
self.total_num_lines = len(self.file_lines)
5052

5153
# access a surface with a particular id
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/env/python
2+
3+
import unittest
4+
import subprocess
5+
6+
class TestWindowsLineEndings(unittest.TestCase):
7+
def test_windows_line_endings(self):
8+
return_code = subprocess.call("python3 ../../csg2csg.py -f files/spheres.i -o all", shell=True)
9+
self.assertEqual(return_code,0)
10+
return_code = subprocess.call("sed -e 's/$/\r/' files/spheres.i > spheres_win.i # UNIX to DOS (adding CRs)", shell=True)
11+
return_code = subprocess.call("python3 ../../csg2csg.py -f spheres_win.i -o all", shell=True)
12+
self.assertEqual(return_code,0)
13+
14+
if __name__ == '__main__':
15+
unittest.main()
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
test problem for csg2csg
2+
1 0 -1 imp:n=1
3+
2 0 -2 1 imp:n=1
4+
3 0 -3 2 imp:n=1
5+
4 0 3 imp:n=0
6+
7+
1 so 10
8+
2 so 20
9+
3 so 30
10+
11+
print
12+
nps 1e6

python/test/integration/run_tests

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
set -ex
3+
4+
for i in `ls *.py` ; do
5+
python3 $i
6+
done

python/test/run_tests

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,7 @@ set -ex
44
for i in `ls *.py` ; do
55
python3 $i
66
done
7+
8+
cd integration
9+
./run_tests
10+
cd ..

0 commit comments

Comments
 (0)