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

Method extract_from_str

Lib/test/test_tools/test_i18n.py:95–111  ·  view source on GitHub ↗

Return all msgids extracted from module_content.

(self, module_content, *, args=(), strict=True,
                         with_stderr=False, raw=False)

Source from the content-addressed store, hash-verified

93 self.assertEqual(normalize_POT_file(expected), normalize_POT_file(actual))
94
95 def extract_from_str(self, module_content, *, args=(), strict=True,
96 with_stderr=False, raw=False):
97 """Return all msgids extracted from module_content."""
98 filename = 'test.py'
99 with temp_cwd(None):
100 with open(filename, 'w', encoding='utf-8') as fp:
101 fp.write(module_content)
102 res = assert_python_ok('-Xutf8', self.script, *args, filename)
103 if strict:
104 self.assertEqual(res.err, b'')
105 with open('messages.pot', encoding='utf-8') as fp:
106 data = fp.read()
107 if not raw:
108 data = self.get_msgids(data)
109 if not with_stderr:
110 return data
111 return data, res.err
112
113 def extract_docstrings_from_str(self, module_content):
114 """Return all docstrings extracted from module_content."""

Calls 7

get_msgidsMethod · 0.95
temp_cwdFunction · 0.90
assert_python_okFunction · 0.90
openFunction · 0.50
writeMethod · 0.45
assertEqualMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected