[Python-checkins] bpo-46425: fix direct invocation of `test_traceback` (GH-30746)
asvetlov
webhook-mailer at python.org
Sat Jan 22 11:03:17 EST 2022
https://github.com/python/cpython/commit/101a184d49756043a0c39dde6eca08b1891137a2
commit: 101a184d49756043a0c39dde6eca08b1891137a2
branch: main
author: Nikita Sobolev <mail at sobolevn.me>
committer: asvetlov <andrew.svetlov at gmail.com>
date: 2022-01-22T18:03:13+02:00
summary:
bpo-46425: fix direct invocation of `test_traceback` (GH-30746)
files:
M Lib/test/test_traceback.py
diff --git a/Lib/test/test_traceback.py b/Lib/test/test_traceback.py
index a0e4656d3d9ea..966ff2a1241ca 100644
--- a/Lib/test/test_traceback.py
+++ b/Lib/test/test_traceback.py
@@ -18,6 +18,7 @@
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 @@ def __str__(self):
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 @@ def __str__(self):
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 ####
More information about the Python-checkins
mailing list