diff options
author | Nikita Sobolev <mail@sobolevn.me> | 2022-01-22 16:03:13 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-22 16:03:13 (GMT) |
commit | 101a184d49756043a0c39dde6eca08b1891137a2 (patch) | |
tree | f05d05dc6dd6bff10a720dc33a16c892f9fc412e | |
parent | 2d03b73cc9c0dada3243eab1373a46dbd98d24a0 (diff) | |
download | cpython-101a184d49756043a0c39dde6eca08b1891137a2.zip cpython-101a184d49756043a0c39dde6eca08b1891137a2.tar.gz cpython-101a184d49756043a0c39dde6eca08b1891137a2.tar.bz2 |
bpo-46425: fix direct invocation of `test_traceback` (GH-30746)
-rw-r--r-- | Lib/test/test_traceback.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Lib/test/test_traceback.py b/Lib/test/test_traceback.py index a0e4656..966ff2a 100644 --- a/Lib/test/test_traceback.py +++ b/Lib/test/test_traceback.py @@ -18,6 +18,7 @@ import textwrap import traceback from functools import partial +MODULE_PREFIX = f'{__name__}.' if __name__ == '__main__' else '' test_code = namedtuple('code', ['co_filename', 'co_name']) test_code.co_positions = lambda _: iter([(6, 6, 0, 0)]) @@ -1312,7 +1313,7 @@ class BaseExceptionReportingTests: str_value = 'I am X' str_name = '.'.join([A.B.X.__module__, A.B.X.__qualname__]) exp = "%s: %s\n" % (str_name, str_value) - self.assertEqual(exp, err) + self.assertEqual(exp, MODULE_PREFIX + err) def test_exception_modulename(self): class X(Exception): @@ -1349,7 +1350,7 @@ class BaseExceptionReportingTests: err = self.get_report(X()) str_value = '<exception str() failed>' str_name = '.'.join([X.__module__, X.__qualname__]) - self.assertEqual(err, f"{str_name}: {str_value}\n") + self.assertEqual(MODULE_PREFIX + err, f"{str_name}: {str_value}\n") # #### Exception Groups #### |