(self)
| 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' |
| 1237 | line_num = 3 |
| 1238 | expected_file_line = linecache.getline(file_name, line_num).strip() |
| 1239 | message = 'msg' |
| 1240 | category = Warning |
| 1241 | file_object = StringIO() |
| 1242 | expect = self.module.formatwarning(message, category, file_name, |
| 1243 | line_num) |
| 1244 | self.module.showwarning(message, category, file_name, line_num, |
| 1245 | file_object) |
| 1246 | self.assertEqual(file_object.getvalue(), expect) |
| 1247 | # Test 'line' argument. |
| 1248 | expected_file_line += "for the win!" |
| 1249 | expect = self.module.formatwarning(message, category, file_name, |
| 1250 | line_num, expected_file_line) |
| 1251 | file_object = StringIO() |
| 1252 | self.module.showwarning(message, category, file_name, line_num, |
| 1253 | file_object, expected_file_line) |
| 1254 | self.assertEqual(expect, file_object.getvalue()) |
| 1255 | |
| 1256 | def test_formatwarning_override(self): |
| 1257 | # bpo-35178: Test that a custom formatwarning function gets the 'line' |
nothing calls this directly
no test coverage detected