05.11., 9:00 - 11:00: Due to updates GitLab may be unavailable for some minutes between 09:00 and 11:00.

Commit d7a1433e authored by eckhart's avatar eckhart

- test/test_dhparser.py, test_testing.py: properly remove test-data directories

parent f6974452
......@@ -104,7 +104,7 @@ from DHParser import logging, is_filename, load_if_file, \\
DHPARSER_MAIN = '''
def kompiliere_mlw(source, log_dir=''):
def compile_src(source, log_dir=''):
"""Compiles ``source`` and returns (result, errors, ast).
"""
with logging(log_dir):
......@@ -131,7 +131,7 @@ if __name__ == "__main__":
file_name, log_dir = sys.argv[1], ''
if file_name in ['-d', '--debug'] and len(sys.argv) > 2:
file_name, log_dir = sys.argv[2], 'LOGS'
result, errors, ast = kompiliere_mlw(file_name, log_dir)
result, errors, ast = compile_src(file_name, log_dir)
if errors:
cwd = os.getcwd()
rel_path = file_name[len(cwd):] if file_name.startswith(cwd) else file_name
......
......@@ -26,25 +26,29 @@ import sys
sys.path.extend(['../', './'])
scriptdir = os.path.dirname(os.path.realpath(__file__))
class TestDHParserCommandLineTool:
def setup(self):
self.cwd = os.getcwd()
os.chdir(scriptdir)
if not os.path.exists('testdata'):
os.mkdir('testdata')
def teardown(self):
if os.path.exists('testdata/neu') and os.path.isdir('testdata/neu'):
shutil.rmtree('testdata/neu')
if os.path.exists('testdata') and not os.listdir('testdata'):
os.rmdir('testdata')
os.chdir(self.cwd)
def test_dhparser(self):
# cwd = os.getcwd()
os.system('python ../dhparser.py testdata/neu >/dev/null')
os.system('python testdata/neu/tst_neu_grammar.py >/dev/null')
os.system('python testdata/neu/neuCompiler.py testdata/neu/example.dsl >testdata/neu/example.xml')
with open('testdata/neu/example.xml', 'r', encoding='utf-8') as f:
xml = f.read()
assert xml.find('<document>') >= 0
# os.chdir(cwd)
if __name__ == "__main__":
from DHParser.testing import runner
......
......@@ -138,7 +138,7 @@ class TestCompilerGeneration:
sys.path.append(self.tmp)
from TestCompilerGenerationCompiler import compile_src
# print(kompiliere_mlw)
# print(compile_src)
result, errors, ast = compile_src(self.trivial_text)
......
......@@ -202,7 +202,7 @@ class TestGrammarTest:
files = os.listdir('REPORT')
flag = False
for file in files:
if re.match(r'\d+\.md', file):
if re.match(r'unit_test_\d+\.md', file):
os.remove(os.path.join('REPORT', file))
else:
flag = True
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment