ยปCore Development>Code coverage>Lib/test/test_errno.py

Python code coverage for Lib/test/test_errno.py

#countcontent
1n/a"""Test the errno module
2n/a Roger E. Masse
3n/a"""
4n/a
5n/aimport errno
6n/aimport unittest
7n/a
8n/astd_c_errors = frozenset(['EDOM', 'ERANGE'])
9n/a
10n/aclass ErrnoAttributeTests(unittest.TestCase):
11n/a
12n/a def test_for_improper_attributes(self):
13n/a # No unexpected attributes should be on the module.
14n/a for error_code in std_c_errors:
15n/a self.assertTrue(hasattr(errno, error_code),
16n/a "errno is missing %s" % error_code)
17n/a
18n/a def test_using_errorcode(self):
19n/a # Every key value in errno.errorcode should be on the module.
20n/a for value in errno.errorcode.values():
21n/a self.assertTrue(hasattr(errno, value),
22n/a 'no %s attr in errno' % value)
23n/a
24n/a
25n/aclass ErrorcodeTests(unittest.TestCase):
26n/a
27n/a def test_attributes_in_errorcode(self):
28n/a for attribute in errno.__dict__.keys():
29n/a if attribute.isupper():
30n/a self.assertIn(getattr(errno, attribute), errno.errorcode,
31n/a 'no %s attr in errno.errorcode' % attribute)
32n/a
33n/a
34n/aif __name__ == '__main__':
35n/a unittest.main()