Back to index

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

List of all members.

Public Member Functions

def setUp
def tearDown
def test_error
def test_ignore
def test_always
def test_default
def test_module
def test_once
def test_inheritance
def test_ordering
def test_filterwarnings

Public Attributes

_PyObject_HEAD_EXTRA Py_ssize_t ob_refcnt
struct _typeobjectob_type

Static Public Attributes

 module = c_warnings

Detailed Description

Definition at line 189 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:

def test.test_warnings.FilterTests.test_always (   self) [inherited]

Definition at line 85 of file test_warnings.py.

00085 
00086     def test_always(self):
00087         with original_warnings.catch_warnings(record=True,
00088                 module=self.module) as w:
00089             self.module.resetwarnings()
00090             self.module.filterwarnings("always", category=UserWarning)
00091             message = "FilterTests.test_always"
00092             self.module.warn(message, UserWarning)
00093             self.assertTrue(message, w[-1].message)
00094             self.module.warn(message, UserWarning)
00095             self.assertTrue(w[-1].message, message)

Here is the call graph for this function:

def test.test_warnings.FilterTests.test_default (   self) [inherited]

Definition at line 96 of file test_warnings.py.

00096 
00097     def test_default(self):
00098         with original_warnings.catch_warnings(record=True,
00099                 module=self.module) as w:
00100             self.module.resetwarnings()
00101             self.module.filterwarnings("default", category=UserWarning)
00102             message = UserWarning("FilterTests.test_default")
00103             for x in range(2):
00104                 self.module.warn(message, UserWarning)
00105                 if x == 0:
00106                     self.assertEqual(w[-1].message, message)
00107                     del w[:]
00108                 elif x == 1:
00109                     self.assertEqual(len(w), 0)
00110                 else:
00111                     raise ValueError("loop variant unhandled")

Here is the call graph for this function:

def test.test_warnings.FilterTests.test_error (   self) [inherited]

Definition at line 70 of file test_warnings.py.

00070 
00071     def test_error(self):
00072         with original_warnings.catch_warnings(module=self.module) as w:
00073             self.module.resetwarnings()
00074             self.module.filterwarnings("error", category=UserWarning)
00075             self.assertRaises(UserWarning, self.module.warn,
00076                                 "FilterTests.test_error")

Here is the call graph for this function:

Definition at line 162 of file test_warnings.py.

00162 
00163     def test_filterwarnings(self):
00164         # Test filterwarnings().
00165         # Implicitly also tests resetwarnings().
00166         with original_warnings.catch_warnings(record=True,
00167                 module=self.module) as w:
00168             self.module.filterwarnings("error", "", Warning, "", 0)
00169             self.assertRaises(UserWarning, self.module.warn, 'convert to error')
00170 
00171             self.module.resetwarnings()
00172             text = 'handle normally'
00173             self.module.warn(text)
00174             self.assertEqual(str(w[-1].message), text)
00175             self.assertTrue(w[-1].category is UserWarning)
00176 
00177             self.module.filterwarnings("ignore", "", Warning, "", 0)
00178             text = 'filtered out'
00179             self.module.warn(text)
00180             self.assertNotEqual(str(w[-1].message), text)
00181 
00182             self.module.resetwarnings()
00183             self.module.filterwarnings("error", "hex*", Warning, "", 0)
00184             self.assertRaises(UserWarning, self.module.warn, 'hex/oct')
00185             text = 'nonmatching text'
00186             self.module.warn(text)
00187             self.assertEqual(str(w[-1].message), text)
00188             self.assertTrue(w[-1].category is UserWarning)

Here is the call graph for this function:

def test.test_warnings.FilterTests.test_ignore (   self) [inherited]

Definition at line 77 of file test_warnings.py.

00077 
00078     def test_ignore(self):
00079         with original_warnings.catch_warnings(record=True,
00080                 module=self.module) as w:
00081             self.module.resetwarnings()
00082             self.module.filterwarnings("ignore", category=UserWarning)
00083             self.module.warn("FilterTests.test_ignore", UserWarning)
00084             self.assertEqual(len(w), 0)

Here is the call graph for this function:

Definition at line 141 of file test_warnings.py.

00141 
00142     def test_inheritance(self):
00143         with original_warnings.catch_warnings(module=self.module) as w:
00144             self.module.resetwarnings()
00145             self.module.filterwarnings("error", category=Warning)
00146             self.assertRaises(UserWarning, self.module.warn,
00147                                 "FilterTests.test_inheritance", UserWarning)

Here is the call graph for this function:

def test.test_warnings.FilterTests.test_module (   self) [inherited]

Definition at line 112 of file test_warnings.py.

00112 
00113     def test_module(self):
00114         with original_warnings.catch_warnings(record=True,
00115                 module=self.module) as w:
00116             self.module.resetwarnings()
00117             self.module.filterwarnings("module", category=UserWarning)
00118             message = UserWarning("FilterTests.test_module")
00119             self.module.warn(message, UserWarning)
00120             self.assertEqual(w[-1].message, message)
00121             del w[:]
00122             self.module.warn(message, UserWarning)
00123             self.assertEqual(len(w), 0)

Here is the call graph for this function:

def test.test_warnings.FilterTests.test_once (   self) [inherited]

Definition at line 124 of file test_warnings.py.

00124 
00125     def test_once(self):
00126         with original_warnings.catch_warnings(record=True,
00127                 module=self.module) as w:
00128             self.module.resetwarnings()
00129             self.module.filterwarnings("once", category=UserWarning)
00130             message = UserWarning("FilterTests.test_once")
00131             self.module.warn_explicit(message, UserWarning, "test_warnings.py",
00132                                     42)
00133             self.assertEqual(w[-1].message, message)
00134             del w[:]
00135             self.module.warn_explicit(message, UserWarning, "test_warnings.py",
00136                                     13)
00137             self.assertEqual(len(w), 0)
00138             self.module.warn_explicit(message, UserWarning, "test_warnings2.py",
00139                                     42)
00140             self.assertEqual(len(w), 0)

Here is the call graph for this function:

Definition at line 148 of file test_warnings.py.

00148 
00149     def test_ordering(self):
00150         with original_warnings.catch_warnings(record=True,
00151                 module=self.module) as w:
00152             self.module.resetwarnings()
00153             self.module.filterwarnings("ignore", category=UserWarning)
00154             self.module.filterwarnings("error", category=UserWarning,
00155                                         append=True)
00156             del w[:]
00157             try:
00158                 self.module.warn("FilterTests.test_ordering", UserWarning)
00159             except UserWarning:
00160                 self.fail("order handling for actions failed")
00161             self.assertEqual(len(w), 0)

Here is the call graph for this function:


Member Data Documentation

Definition at line 190 of file test_warnings.py.

Definition at line 107 of file object.h.

struct _typeobject* _object::ob_type [inherited]

Definition at line 108 of file object.h.


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