Back to index

python3.2  3.2.2
Public Member Functions
test.test_warnings.WarningsDisplayTests Class Reference
Inheritance diagram for test.test_warnings.WarningsDisplayTests:
Inheritance graph
[legend]

List of all members.

Public Member Functions

def test_formatwarning
def test_showwarning

Detailed Description

Test the displaying of warnings and the ability to overload functions
related to displaying warnings.

Definition at line 558 of file test_warnings.py.


Member Function Documentation

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:


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