Skip to content

Commit 2dd1a1d

Browse files
committed
moved test files to be dialect specific
1 parent 62ccd35 commit 2dd1a1d

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

tests/test_parsing.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
_test_files_dir = os.path.join(_this_path, 'test-files')
2424

2525
class FileParsingTest(unittest.TestCase):
26-
filename = os.path.join(_test_files_dir, 'random-sample-1.gcode')
26+
filename = os.path.join(_test_files_dir, 'linuxcnc', 'random-sample-1.gcode')
2727

2828
def test_file(self):
2929
m = Machine()
@@ -33,16 +33,20 @@ def test_file(self):
3333
m.process_block(line.block)
3434

3535

36+
# Get list of test files
37+
_filetype_regex = re.compile(r'\.(tap|nc|ngc|gcode)$', re.IGNORECASE)
38+
_test_files = set()
39+
for dialect in ['linuxcnc']: # FIXME: get list of all dialects
40+
for filename in glob.glob(os.path.join(_test_files_dir, dialect, '*')):
41+
if _filetype_regex.search(filename):
42+
_test_files.add(filename)
3643

37-
# Create inheriting class for each gcode file in the _test_files_dir directory
38-
_filetype_regex = re.compile(r'^.*\.(tap|nc|ngc|gcode)$', re.IGNORECASE)
39-
_test_files = [f for f in glob.glob(os.path.join(_test_files_dir, '*')) if _filetype_regex.search(f)]
44+
# remove default test file:
45+
_test_files.discard(FileParsingTest.filename)
4046

47+
# Create inheriting class for each gcode file in the _test_files_dir directory
4148
for (i, filename) in enumerate(sorted(_test_files)):
4249
basename = os.path.basename(filename)
43-
if basename == os.path.basename(FileParsingTest.filename):
44-
break # already defined as a test
45-
4650
class_name = "FileParsingTest_" + re.sub(r"""[^a-zA-Z0-9]""", '_', basename)
4751
globals()[class_name] = type(class_name, (FileParsingTest,), {
4852
'filename': filename,

0 commit comments

Comments
 (0)