Back to index

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

List of all members.

Public Member Functions

def setUp
def tearDown
def test_formatwarning
def test_showwarning

Static Public Attributes

 module = c_warnings

Detailed Description

Definition at line 602 of file test_warnings.py.


Member Function Documentation

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

Definition at line 47 of file test_warnings.py.

00047 
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 test_warnings.py.

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

Here is the caller graph for this function:

Definition at line 563 of file test_warnings.py.

00563 
00564     def test_formatwarning(self):
00565         message = "msg"
00566         category = Warning
00567         file_name = os.path.splitext(warning_tests.__file__)[0] + '.py'
00568         line_num = 3
00569         file_line = linecache.getline(file_name, line_num).strip()
00570         format = "%s:%s: %s: %s\n  %s\n"
00571         expect = format % (file_name, line_num, category.__name__, message,
00572                             file_line)
00573         self.assertEqual(expect, self.module.formatwarning(message,
00574                                                 category, file_name, line_num))
00575         # Test the 'line' argument.
00576         file_line += " for the win!"
00577         expect = format % (file_name, line_num, category.__name__, message,
00578                             file_line)
00579         self.assertEqual(expect, self.module.formatwarning(message,
00580                                     category, file_name, line_num, file_line))

Here is the call graph for this function:

Definition at line 581 of file test_warnings.py.

00581 
00582     def test_showwarning(self):
00583         file_name = os.path.splitext(warning_tests.__file__)[0] + '.py'
00584         line_num = 3
00585         expected_file_line = linecache.getline(file_name, line_num).strip()
00586         message = 'msg'
00587         category = Warning
00588         file_object = StringIO()
00589         expect = self.module.formatwarning(message, category, file_name,
00590                                             line_num)
00591         self.module.showwarning(message, category, file_name, line_num,
00592                                 file_object)
00593         self.assertEqual(file_object.getvalue(), expect)
00594         # Test 'line' argument.
00595         expected_file_line += "for the win!"
00596         expect = self.module.formatwarning(message, category, file_name,
00597                                             line_num, expected_file_line)
00598         file_object = StringIO()
00599         self.module.showwarning(message, category, file_name, line_num,
00600                                 file_object, expected_file_line)
00601         self.assertEqual(expect, file_object.getvalue())

Here is the call graph for this function:


Member Data Documentation

Definition at line 603 of file test_warnings.py.


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