mirror of
https://git.mirrors.martin98.com/https://github.com/petaflot/pygcode
synced 2025-07-15 12:51:49 +08:00
moved test files to be dialect specific
This commit is contained in:
parent
62ccd35da7
commit
2dd1a1d974
@ -23,7 +23,7 @@ _this_path = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentfram
|
|||||||
_test_files_dir = os.path.join(_this_path, 'test-files')
|
_test_files_dir = os.path.join(_this_path, 'test-files')
|
||||||
|
|
||||||
class FileParsingTest(unittest.TestCase):
|
class FileParsingTest(unittest.TestCase):
|
||||||
filename = os.path.join(_test_files_dir, 'random-sample-1.gcode')
|
filename = os.path.join(_test_files_dir, 'linuxcnc', 'random-sample-1.gcode')
|
||||||
|
|
||||||
def test_file(self):
|
def test_file(self):
|
||||||
m = Machine()
|
m = Machine()
|
||||||
@ -33,16 +33,20 @@ class FileParsingTest(unittest.TestCase):
|
|||||||
m.process_block(line.block)
|
m.process_block(line.block)
|
||||||
|
|
||||||
|
|
||||||
|
# Get list of test files
|
||||||
|
_filetype_regex = re.compile(r'\.(tap|nc|ngc|gcode)$', re.IGNORECASE)
|
||||||
|
_test_files = set()
|
||||||
|
for dialect in ['linuxcnc']: # FIXME: get list of all dialects
|
||||||
|
for filename in glob.glob(os.path.join(_test_files_dir, dialect, '*')):
|
||||||
|
if _filetype_regex.search(filename):
|
||||||
|
_test_files.add(filename)
|
||||||
|
|
||||||
|
# remove default test file:
|
||||||
|
_test_files.discard(FileParsingTest.filename)
|
||||||
|
|
||||||
# Create inheriting class for each gcode file in the _test_files_dir directory
|
# Create inheriting class for each gcode file in the _test_files_dir directory
|
||||||
_filetype_regex = re.compile(r'^.*\.(tap|nc|ngc|gcode)$', re.IGNORECASE)
|
|
||||||
_test_files = [f for f in glob.glob(os.path.join(_test_files_dir, '*')) if _filetype_regex.search(f)]
|
|
||||||
|
|
||||||
for (i, filename) in enumerate(sorted(_test_files)):
|
for (i, filename) in enumerate(sorted(_test_files)):
|
||||||
basename = os.path.basename(filename)
|
basename = os.path.basename(filename)
|
||||||
if basename == os.path.basename(FileParsingTest.filename):
|
|
||||||
break # already defined as a test
|
|
||||||
|
|
||||||
class_name = "FileParsingTest_" + re.sub(r"""[^a-zA-Z0-9]""", '_', basename)
|
class_name = "FileParsingTest_" + re.sub(r"""[^a-zA-Z0-9]""", '_', basename)
|
||||||
globals()[class_name] = type(class_name, (FileParsingTest,), {
|
globals()[class_name] = type(class_name, (FileParsingTest,), {
|
||||||
'filename': filename,
|
'filename': filename,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user