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

Commit 1dde23fc authored by di68kap's avatar di68kap

- test_dhparser.py: windows bugfix

parent 8e138c75
...@@ -228,7 +228,7 @@ if __name__ == "__main__": ...@@ -228,7 +228,7 @@ if __name__ == "__main__":
if not argv[1].endswith(')'): if not argv[1].endswith(')'):
# argv does not seem to be a command (e.g. "identify()") but a file name or path # argv does not seem to be a command (e.g. "identify()") but a file name or path
argv[1] = os.path.abspath(argv[1]) argv[1] = os.path.abspath(argv[1])
print(argv[1]) # print(argv[1])
try: try:
result = asyncio_run(send_request(argv[1], host, port)) result = asyncio_run(send_request(argv[1], host, port))
except ConnectionRefusedError: except ConnectionRefusedError:
......
...@@ -23,12 +23,16 @@ limitations under the License. ...@@ -23,12 +23,16 @@ limitations under the License.
import os import os
import platform import platform
import shutil import shutil
import subprocess
import sys import sys
sys.path.extend(['../', './']) sys.path.extend(['../', './'])
scriptdir = os.path.dirname(os.path.realpath(__file__)) scriptdir = os.path.dirname(os.path.realpath(__file__))
def system(s: str) -> int:
return subprocess.call(s.split(' '), shell=True)
class TestDHParserCommandLineTool: class TestDHParserCommandLineTool:
def setup(self): def setup(self):
self.cwd = os.getcwd() self.cwd = os.getcwd()
...@@ -40,7 +44,7 @@ class TestDHParserCommandLineTool: ...@@ -40,7 +44,7 @@ class TestDHParserCommandLineTool:
def teardown(self): def teardown(self):
if os.path.exists('testdata/neu/neuServer.py'): if os.path.exists('testdata/neu/neuServer.py'):
os.system(self.python + 'testdata/neu/neuServer.py --stopserver' + self.nulldevice) system(self.python + 'testdata/neu/neuServer.py --stopserver' + self.nulldevice)
if os.path.exists('testdata/neu') and os.path.isdir('testdata/neu'): if os.path.exists('testdata/neu') and os.path.isdir('testdata/neu'):
shutil.rmtree('testdata/neu') shutil.rmtree('testdata/neu')
if os.path.exists('testdata') and not os.listdir('testdata'): if os.path.exists('testdata') and not os.listdir('testdata'):
...@@ -49,9 +53,9 @@ class TestDHParserCommandLineTool: ...@@ -49,9 +53,9 @@ class TestDHParserCommandLineTool:
def test_dhparser(self): def test_dhparser(self):
# test compiler creation and execution # test compiler creation and execution
os.system(self.python + '../DHParser/scripts/dhparser.py testdata/neu ' + self.nulldevice) system(self.python + '../DHParser/scripts/dhparser.py testdata/neu ' + self.nulldevice)
os.system(self.python + 'testdata/neu/tst_neu_grammar.py ' + self.nulldevice) system(self.python + 'testdata/neu/tst_neu_grammar.py ' + self.nulldevice)
os.system(self.python + 'testdata/neu/neuCompiler.py testdata/neu/example.dsl ' system(self.python + 'testdata/neu/neuCompiler.py testdata/neu/example.dsl '
'>testdata/neu/example.xml') '>testdata/neu/example.xml')
with open('testdata/neu/example.xml', 'r', encoding='utf-8') as f: with open('testdata/neu/example.xml', 'r', encoding='utf-8') as f:
xml = f.read() xml = f.read()
...@@ -60,15 +64,14 @@ class TestDHParserCommandLineTool: ...@@ -60,15 +64,14 @@ class TestDHParserCommandLineTool:
os.remove('testdata/neu/example.xml') os.remove('testdata/neu/example.xml')
# test server # test server
os.system(self.python + 'testdata/neu/neuServer.py --stopserver' + self.nulldevice) system(self.python + 'testdata/neu/neuServer.py --stopserver' + self.nulldevice)
os.system(self.python + 'testdata/neu/neuServer.py testdata/neu/example.dsl ' system(self.python + 'testdata/neu/neuServer.py testdata/neu/example.dsl '
'>testdata/neu/example.xml') '>testdata/neu/example.xml')
with open('testdata/neu/example.xml', 'r', encoding='utf-8') as f: with open('testdata/neu/example.xml', 'r', encoding='utf-8') as f:
json = f.read() json = f.read()
assert json.find('document') >= 0, json assert json.find('document') >= 0, json
os.system(self.python + 'testdata/neu/neuServer.py testdata/neu/example.dsl ' system(self.python + 'testdata/neu/neuServer.py testdata/neu/example.dsl ' + self.nulldevice)
'>testdata/neu/example.xml') system(self.python + 'testdata/neu/neuServer.py --stopserver' + self.nulldevice)
os.system(self.python + 'testdata/neu/neuServer.py --stopserver' + self.nulldevice)
pass pass
......
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