Back to index

python3.2  3.2.2
Public Member Functions | Static Public Attributes
test.test_warnings.CWCmdLineTests Class Reference
Inheritance diagram for test.test_warnings.CWCmdLineTests:
Inheritance graph
Collaboration diagram for test.test_warnings.CWCmdLineTests:
Collaboration graph

List of all members.

Public Member Functions

def setUp
def tearDown
def test_improper_input
def test_improper_option
def test_warnings_bootstrap

Static Public Attributes

 module = c_warnings

Detailed Description

Definition at line 413 of file

Member Function Documentation

def test.test_warnings.BaseTest.setUp (   self) [inherited]

Definition at line 47 of file

00048     def setUp(self):
00049         # The __warningregistry__ needs to be in a pristine state for tests
00050         # to work properly.
00051         if '__warningregistry__' in globals():
00052             del globals()['__warningregistry__']
00053         if hasattr(warning_tests, '__warningregistry__'):
00054             del warning_tests.__warningregistry__
00055         if hasattr(sys, '__warningregistry__'):
00056             del sys.__warningregistry__
00057         # The 'warnings' module must be explicitly set so that the proper
00058         # interaction between _warnings and 'warnings' can be controlled.
00059         sys.modules['warnings'] = self.module
00060         super(BaseTest, self).setUp()

Here is the caller graph for this function:

def test.test_warnings.BaseTest.tearDown (   self) [inherited]

Definition at line 61 of file

00062     def tearDown(self):
00063         sys.modules['warnings'] = original_warnings
00064         super(BaseTest, self).tearDown()

Here is the caller graph for this function:

Definition at line 384 of file

00385     def test_improper_input(self):
00386         # Uses the private _setoption() function to test the parsing
00387         # of command-line warning arguments
00388         with original_warnings.catch_warnings(module=self.module):
00389             self.assertRaises(self.module._OptionError,
00390                               self.module._setoption, '1:2:3:4:5:6')
00391             self.assertRaises(self.module._OptionError,
00392                               self.module._setoption, 'bogus::Warning')
00393             self.assertRaises(self.module._OptionError,
00394                               self.module._setoption, 'ignore:2::4:-5')
00395             self.module._setoption('error::Warning::0')
00396             self.assertRaises(UserWarning, self.module.warn, 'convert to error')

Here is the call graph for this function:

Definition at line 397 of file

00398     def test_improper_option(self):
00399         # Same as above, but check that the message is printed out when
00400         # the interpreter is executed. This also checks that options are
00401         # actually parsed at all.
00402         rc, out, err = assert_python_ok("-Wxxx", "-c", "pass")
00403         self.assertIn(b"Invalid -W option ignored: invalid action: 'xxx'", err)

Here is the call graph for this function:

Definition at line 404 of file

00405     def test_warnings_bootstrap(self):
00406         # Check that the warnings module does get loaded when -W<some option>
00407         # is used (see issue #10372 for an example of silent bootstrap failure).
00408         rc, out, err = assert_python_ok("-Wi", "-c",
00409             "import sys; sys.modules['warnings'].warn('foo', RuntimeWarning)")
00410         # '-Wi' was observed
00411         self.assertFalse(out.strip())
00412         self.assertNotIn(b'RuntimeWarning', err)

Here is the call graph for this function:

Member Data Documentation

Definition at line 414 of file

The documentation for this class was generated from the following file: