MCPcopy Index your code
hub / github.com/python/cpython / assert_ns_equal

Method assert_ns_equal

Lib/test/test_interpreters/utils.py:477–492  ·  view source on GitHub ↗
(self, ns1, ns2, msg=None)

Source from the content-addressed store, hash-verified

475 return stdout, stderr
476
477 def assert_ns_equal(self, ns1, ns2, msg=None):
478 # This is mostly copied from TestCase.assertDictEqual.
479 self.assertEqual(type(ns1), type(ns2))
480 if ns1 == ns2:
481 return
482
483 import difflib
484 import pprint
485 from unittest.util import _common_shorten_repr
486 standardMsg = '%s != %s' % _common_shorten_repr(ns1, ns2)
487 diff = ('\n' + '\n'.join(difflib.ndiff(
488 pprint.pformat(vars(ns1)).splitlines(),
489 pprint.pformat(vars(ns2)).splitlines())))
490 diff = f'namespace({diff})'
491 standardMsg = self._truncateMessage(standardMsg, diff)
492 self.fail(self._formatMessage(msg, standardMsg))
493
494 def _run_string(self, interp, script):
495 wrapped, results = _captured_script(script, exc=False)

Callers 4

test_new_configMethod · 0.45
test_createMethod · 0.45
test_get_configMethod · 0.45
test_execMethod · 0.45

Calls 8

_common_shorten_reprFunction · 0.90
pformatMethod · 0.80
_truncateMessageMethod · 0.80
_formatMessageMethod · 0.80
assertEqualMethod · 0.45
joinMethod · 0.45
splitlinesMethod · 0.45
failMethod · 0.45

Tested by 4

test_new_configMethod · 0.36
test_createMethod · 0.36
test_get_configMethod · 0.36
test_execMethod · 0.36