MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_subinterp_intern_singleton

Method test_subinterp_intern_singleton

Lib/test/test_sys.py:836–851  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

834 @support.cpython_only
835 @requires_subinterpreters
836 def test_subinterp_intern_singleton(self):
837 # Implementation detail: singletons are used for 0- and 1-character
838 # latin1 strings.
839 for s in '', '\n', '_', 'x', '\0', '\N{CEDILLA}', '\xff':
840 with self.subTest(s=s):
841 interp = interpreters.create()
842 interp.exec(textwrap.dedent(f'''
843 import sys
844
845 # set `s`, avoid parser interning & constant folding
846 s = str({s.encode()!r}, 'utf-8')
847
848 assert id(s) == {id(s)}
849 t = sys.intern(s)
850 '''))
851 self.assertTrue(sys._is_interned(s))
852
853 def test_sys_flags(self):
854 self.assertTrue(sys.flags)

Callers

nothing calls this directly

Calls 7

idFunction · 0.85
subTestMethod · 0.80
execMethod · 0.80
dedentMethod · 0.80
assertTrueMethod · 0.80
createMethod · 0.45
encodeMethod · 0.45

Tested by

no test coverage detected