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

Method test_formatwarning

Lib/test/test_warnings/__init__.py:1217–1233  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1215 related to displaying warnings."""
1216
1217 def test_formatwarning(self):
1218 message = "msg"
1219 category = Warning
1220 file_name = os.path.splitext(warning_tests.__file__)[0] + '.py'
1221 line_num = 5
1222 file_line = linecache.getline(file_name, line_num).strip()
1223 format = "%s:%s: %s: %s\n %s\n"
1224 expect = format % (file_name, line_num, category.__name__, message,
1225 file_line)
1226 self.assertEqual(expect, self.module.formatwarning(message,
1227 category, file_name, line_num))
1228 # Test the 'line' argument.
1229 file_line += " for the win!"
1230 expect = format % (file_name, line_num, category.__name__, message,
1231 file_line)
1232 self.assertEqual(expect, self.module.formatwarning(message,
1233 category, file_name, line_num, file_line))
1234
1235 def test_showwarning(self):
1236 file_name = os.path.splitext(warning_tests.__file__)[0] + '.py'

Callers

nothing calls this directly

Calls 4

splitextMethod · 0.80
stripMethod · 0.45
getlineMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected