mirror of
https://github.com/Telecominfraproject/oopt-gnpy.git
synced 2025-10-30 17:47:50 +00:00
tests: handle Unicode properly for "expected console output"
Let's use the text mode everywhere because Unicode codepoints is what matters. The only catch on Windows turned out to be the default file IO encoding; forcing UTF-8 there fixes all issues in the CI (and it makes sense because that file was written out in a UTF-8 locale, and the system which runs the test suite might be set to something else. This was a rather interesting debugging experience; passing logs over the web and handling "strange" characters as utf-8 did not help. Change-Id: I1fdbe3a115458558b27a81f9eab8e58c9605bae7 Bug: https://github.com/Telecominfraproject/oopt-gnpy/issues/358
This commit is contained in:
@@ -17,14 +17,14 @@ SRC_ROOT = Path(__file__).parent.parent
|
|||||||
('openroadm-Stockholm-Gothenburg', transmission_main_example,
|
('openroadm-Stockholm-Gothenburg', transmission_main_example,
|
||||||
['-e', 'gnpy/example-data/eqpt_config_openroadm.json', 'gnpy/example-data/Sweden_OpenROADM_example_network.json', ]),
|
['-e', 'gnpy/example-data/eqpt_config_openroadm.json', 'gnpy/example-data/Sweden_OpenROADM_example_network.json', ]),
|
||||||
))
|
))
|
||||||
def test_example_invocation(capfdbinary, output, handler, args):
|
def test_example_invocation(capfd, output, handler, args):
|
||||||
'''Make sure that our examples produce useful output'''
|
'''Make sure that our examples produce useful output'''
|
||||||
os.chdir(SRC_ROOT)
|
os.chdir(SRC_ROOT)
|
||||||
expected = open(SRC_ROOT / 'tests' / 'invocation' / output, mode='rb').read()
|
expected = open(SRC_ROOT / 'tests' / 'invocation' / output, mode='r', encoding='utf-8').read()
|
||||||
handler(args)
|
handler(args)
|
||||||
captured = capfdbinary.readouterr()
|
captured = capfd.readouterr()
|
||||||
assert captured.out.decode('utf-8') == expected.decode('utf-8')
|
assert captured.out == expected
|
||||||
assert captured.err == b''
|
assert captured.err == ''
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('program', ('gnpy-transmission-example', 'gnpy-path-request'))
|
@pytest.mark.parametrize('program', ('gnpy-transmission-example', 'gnpy-path-request'))
|
||||||
|
|||||||
Reference in New Issue
Block a user