diff options
Diffstat (limited to 'clients/tests/test-client.py')
| -rwxr-xr-x | clients/tests/test-client.py | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/clients/tests/test-client.py b/clients/tests/test-client.py index ff5a3604..c98db75d 100755 --- a/clients/tests/test-client.py +++ b/clients/tests/test-client.py @@ -61,6 +61,13 @@ ENV_NM_TEST_CLIENT_CHECK_L10N = 'NM_TEST_CLIENT_CHECK_L10N' # on disk with the expected output. ENV_NM_TEST_REGENERATE = 'NM_TEST_REGENERATE' +# whether the file location should include the line number. That is useful +# only for debugging, to correlate the expected output with the test. +# Obviously, since the expected output is commited to git without line numbers, +# you'd have to first NM_TEST_REGENERATE the test expected data, with line +# numbers enabled. +ENV_NM_TEST_WITH_LINENO = 'NM_TEST_WITH_LINENO' + # ############################################################################### @@ -287,6 +294,8 @@ class Configuration: # which we assert. That is useful, if there are intentional changes and # we want to regenerate the expected output. v = (os.environ.get(ENV_NM_TEST_REGENERATE, '0') == '1') + elif name == ENV_NM_TEST_WITH_LINENO: + v = (os.environ.get(ENV_NM_TEST_WITH_LINENO, '0') == '1') else: raise Exception() self._values[name] = v @@ -561,15 +570,18 @@ class TestNmcli(NmTestBase): # the file, so that the user can easier find the source (when looking at the .expected files) self.assertTrue(os.path.abspath(frame.f_code.co_filename).endswith('/'+PathConfiguration.canonical_script_filename())) - calling_location = '%s:%d:%s()/%d' % (PathConfiguration.canonical_script_filename(), frame.f_lineno, frame.f_code.co_name, calling_num) + if conf.get(ENV_NM_TEST_WITH_LINENO): + calling_location = '%s:%d:%s()/%d' % (PathConfiguration.canonical_script_filename(), frame.f_lineno, frame.f_code.co_name, calling_num) + else: + calling_location = '%s:%s()/%d' % (PathConfiguration.canonical_script_filename(), frame.f_code.co_name, calling_num) if lang is None or lang == 'C': lang = 'C' language = '' - elif lang is 'de': + elif lang == 'de': lang = 'de_DE.utf8' language = 'de' - elif lang is 'pl': + elif lang == 'pl': lang = 'pl_PL.UTF-8' language = 'pl' else: @@ -764,7 +776,7 @@ class TestNmcli(NmTestBase): self.fail("Unexpected output of command, expected %s. Rerun test with NM_TEST_REGENERATE=1 to regenerate files" % (filename)) if regenerate: - content_new = ''.join([r['content'] for r in results]) + content_new = b''.join([r['content'] for r in results]) if content_new != content_expect: try: with open(filename, 'wb') as content_file: |