• Home
  • Raw
  • Download

Lines Matching full:module

19 def warnings_state(module):  argument
32 original_filters = module.filters
34 module.filters = original_filters[:]
35 module.simplefilter("once")
36 warning_tests.warnings = module
40 module.filters = original_filters
56 # The 'warnings' module must be explicitly set so that the proper
58 sys.modules['warnings'] = self.module
72 self.assertTrue(hasattr(self.module, '__all__'))
76 self.assertSetEqual(set(self.module.__all__),
80 module = c_warnings variable in CPublicAPITests
83 module = py_warnings variable in PyPublicAPITests
90 with original_warnings.catch_warnings(module=self.module) as w:
91 self.module.resetwarnings()
92 self.module.filterwarnings("error", category=UserWarning)
93 self.assertRaises(UserWarning, self.module.warn,
98 module=self.module) as w:
99 self.module.resetwarnings()
100 self.module.filterwarnings("ignore", category=UserWarning)
101 self.module.warn("FilterTests.test_ignore", UserWarning)
106 module=self.module) as w:
107 self.module.resetwarnings()
108 self.module.filterwarnings("always", category=UserWarning)
111 self.module.warn(message, UserWarning)
121 module=self.module) as w:
122 self.module.resetwarnings()
123 self.module.filterwarnings("default", category=UserWarning)
126 self.module.warn(message, UserWarning)
137 module=self.module) as w:
138 self.module.resetwarnings()
139 self.module.filterwarnings("module", category=UserWarning)
141 self.module.warn(message, UserWarning)
144 self.module.warn(message, UserWarning)
149 module=self.module) as w:
150 self.module.resetwarnings()
151 self.module.filterwarnings("once", category=UserWarning)
153 self.module.warn_explicit(message, UserWarning, "test_warnings.py",
157 self.module.warn_explicit(message, UserWarning, "test_warnings.py",
160 self.module.warn_explicit(message, UserWarning, "test_warnings2.py",
165 with original_warnings.catch_warnings(module=self.module) as w:
166 self.module.resetwarnings()
167 self.module.filterwarnings("error", category=Warning)
168 self.assertRaises(UserWarning, self.module.warn,
173 module=self.module) as w:
174 self.module.resetwarnings()
175 self.module.filterwarnings("ignore", category=UserWarning)
176 self.module.filterwarnings("error", category=UserWarning,
180 self.module.warn("FilterTests.test_ordering", UserWarning)
189 module=self.module) as w:
190 self.module.filterwarnings("error", "", Warning, "", 0)
191 self.assertRaises(UserWarning, self.module.warn, 'convert to error')
193 self.module.resetwarnings()
195 self.module.warn(text)
199 self.module.filterwarnings("ignore", "", Warning, "", 0)
201 self.module.warn(text)
204 self.module.resetwarnings()
205 self.module.filterwarnings("error", "hex*", Warning, "", 0)
206 self.assertRaises(UserWarning, self.module.warn, 'hex/oct')
208 self.module.warn(text)
214 module=self.module) as w:
215 self.module.simplefilter("ignore", UserWarning)
216 self.module.filterwarnings("error", "match", UserWarning)
217 self.assertRaises(UserWarning, self.module.warn, "match")
218 self.assertRaises(UserWarning, self.module.warn, "match prefix")
219 self.module.warn("suffix match")
221 self.module.warn("something completely different")
225 module = c_warnings variable in CFilterTests
228 module = py_warnings variable in PyFilterTests
237 module=self.module) as w:
238 self.module.simplefilter("once")
241 self.module.warn(text)
246 with warnings_state(self.module):
248 module=self.module) as w:
259 with warnings_state(self.module):
261 module=self.module) as w:
284 # If __file__ is not specified and __main__ is not the module name,
285 # then __file__ should be set to the module name.
289 with warnings_state(self.module):
291 module=self.module) as w:
306 with warnings_state(self.module):
308 module=self.module) as w:
325 with warnings_state(self.module):
327 module=self.module) as w:
346 with warnings_state(self.module):
348 module=self.module) as w:
360 self.assertRaises(TypeError, self.module.warn_explicit,
364 self.assertRaises(TypeError, self.module.warn_explicit,
368 self.module.warn_explicit,
382 self.module.warn(BadStrWarning())
386 module = c_warnings variable in CWarnTests
391 self.assertFalse(original_warnings is self.module)
392 self.assertFalse(hasattr(self.module.warn, 'func_code'))
395 module = py_warnings variable in PyWarnTests
400 self.assertFalse(original_warnings is self.module)
401 self.assertTrue(hasattr(self.module.warn, 'func_code'))
409 with original_warnings.catch_warnings(module=self.module):
410 self.assertRaises(self.module._OptionError,
411 self.module._setoption, '1:2:3:4:5:6')
412 self.assertRaises(self.module._OptionError,
413 self.module._setoption, 'bogus::Warning')
414 self.assertRaises(self.module._OptionError,
415 self.module._setoption, 'ignore:2::4:-5')
416 self.module._setoption('error::Warning::0')
417 self.assertRaises(UserWarning, self.module.warn, 'convert to error')
427 # Check that the warnings module does get loaded when -W<some option>
436 module = c_warnings variable in CWCmdLineTests
439 module = py_warnings variable in PyWCmdLineTests
444 """Tests specific to the _warnings module."""
446 module = c_warnings variable in _WarningsTests
450 with original_warnings.catch_warnings(module=self.module) as w:
451 self.module.filterwarnings("error", "", Warning, "", 0)
452 self.assertRaises(UserWarning, self.module.warn,
454 del self.module.filters
455 self.assertRaises(UserWarning, self.module.warn,
463 original_registry = self.module.onceregistry
466 module=self.module) as w:
467 self.module.resetwarnings()
468 self.module.filterwarnings("once", category=UserWarning)
469 self.module.warn_explicit(message, UserWarning, "file", 42)
472 self.module.warn_explicit(message, UserWarning, "file", 42)
475 self.module.onceregistry = {}
477 self.module.warn('onceregistry test')
481 del self.module.onceregistry
483 self.module.warn_explicit(message, UserWarning, "file", 42)
486 self.module.onceregistry = original_registry
491 original = self.module.defaultaction
494 module=self.module) as w:
495 self.module.resetwarnings()
497 self.module.warn_explicit(message, UserWarning, "<test>", 42,
504 del self.module.defaultaction
507 self.module.warn_explicit(message, UserWarning, "<test>", 43,
514 self.module.defaultaction = "ignore"
517 self.module.warn_explicit(message, UserWarning, "<test>", 44,
521 self.module.defaultaction = original
526 with original_warnings.catch_warnings(module=self.module):
527 self.module.filterwarnings("always", category=UserWarning)
528 del self.module.showwarning
530 self.module.warn(text)
535 with original_warnings.catch_warnings(module=self.module):
536 self.module.filterwarnings("always", category=UserWarning)
537 old_showwarning = self.module.showwarning
538 self.module.showwarning = 23
540 self.assertRaises(TypeError, self.module.warn, "Warning!")
542 self.module.showwarning = old_showwarning
547 with original_warnings.catch_warnings(module=self.module):
548 self.module.filterwarnings("always", category=UserWarning)
549 del self.module.showwarning
572 with original_warnings.catch_warnings(module=self.module, record=True) as w:
573 self.module.filterwarnings("always", category=UserWarning)
575 self.module.warn('test', UserWarning)
601 wmod = self.module
602 with original_warnings.catch_warnings(module=wmod):
616 wmod = self.module
617 with original_warnings.catch_warnings(module=wmod):
638 self.assertEqual(expect, self.module.formatwarning(message,
644 self.assertEqual(expect, self.module.formatwarning(message,
657 self.assertEqual(expect, self.module.formatwarning(message,
663 self.assertEqual(expect, self.module.formatwarning(message,
678 self.assertEqual(expect, self.module.formatwarning(message,
683 self.assertEqual(expect, self.module.formatwarning(message,
696 self.assertEqual(expect, self.module.formatwarning(message,
701 self.assertEqual(expect, self.module.formatwarning(message,
711 expect = self.module.formatwarning(message, category, file_name,
713 self.module.showwarning(message, category, file_name, line_num,
718 expect = self.module.formatwarning(message, category, file_name,
721 self.module.showwarning(message, category, file_name, line_num,
726 module = c_warnings variable in CWarningsDisplayTests
729 module = py_warnings variable in PyWarningsDisplayTests
737 wmod = self.module
741 with wmod.catch_warnings(module=wmod, record=True):
746 with wmod.catch_warnings(module=wmod, record=False):
752 wmod = self.module
754 with wmod.catch_warnings(module=wmod, record=True) as w:
768 with wmod.catch_warnings(module=wmod, record=False) as w:
773 wmod = self.module
775 x = wmod.catch_warnings(module=wmod, record=True)
780 x = wmod.catch_warnings(module=wmod, record=False)
786 wmod = self.module
790 with wmod.catch_warnings(module=wmod) as w:
796 # Ensure the default module is this one
805 wmod = self.module
807 self.skipTest('module to test is not loaded warnings module')
836 module = c_warnings variable in CCatchWarningTests
839 module = py_warnings variable in PyCatchWarningTests
875 module = c_warnings variable in CEnvironmentVariableTests
878 module = py_warnings variable in PyEnvironmentVariableTests