8000 bpo-46425: fix direct invocation of `test_traceback` by sobolevn · Pull Request #30746 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-46425: fix direct invocation of test_traceback #30746

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 22, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
bpo-46425: fix direct invocation of test_traceback
  • Loading branch information
sobolevn committed Jan 21, 2022
commit 77c357ec4039c26e6ebe730087ddd2e0350efd98
7 changes: 4 additions & 3 deletions Lib/test/test_traceback.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)])
Expand Down Expand Up @@ -1311,8 +1312,8 @@ def __str__(self):
err = self.get_report(A.B.X())
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)
exp = f"{str_name}: {str_value}\n"
self.assertEqual(exp, MODULE_PREFIX + err)

def test_exception_modulename(self):
class X(Exception):
Expand Down Expand Up @@ -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 ####
Expand Down
0