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

Method test_error_messages

Lib/test/test_tools/test_i18n.py:430–446  ·  view source on GitHub ↗

Test that pygettext outputs error messages to stderr.

(self)

Source from the content-addressed store, hash-verified

428 self.assertIn(b'pygettext -- Python equivalent of xgettext(1)', res.err)
429
430 def test_error_messages(self):
431 """Test that pygettext outputs error messages to stderr."""
432 stderr = self.get_stderr(dedent('''\
433 _(1+2)
434 ngettext('foo')
435 dgettext(*args, 'foo')
436 '''))
437
438 # Normalize line endings on Windows
439 stderr = stderr.decode('utf-8').replace('\r', '')
440
441 self.assertEqual(
442 stderr,
443 "*** test.py:1: Expected a string constant for argument 1, got 1 + 2\n"
444 "*** test.py:2: Expected at least 2 positional argument(s) in gettext call, got 1\n"
445 "*** test.py:3: Variable positional arguments are not allowed in gettext calls\n"
446 )
447
448 def test_extract_all_comments(self):
449 """

Callers

nothing calls this directly

Calls 5

get_stderrMethod · 0.95
dedentFunction · 0.90
replaceMethod · 0.45
decodeMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected