2 """Test the errno module
7 from test
import test_support
10 std_c_errors
= frozenset(['EDOM', 'ERANGE'])
12 class ErrnoAttributeTests(unittest
.TestCase
):
14 def test_for_improper_attributes(self
):
15 # No unexpected attributes should be on the module.
16 for error_code
in std_c_errors
:
17 self
.assertTrue(hasattr(errno
, error_code
),
18 "errno is missing %s" % error_code
)
20 def test_using_errorcode(self
):
21 # Every key value in errno.errorcode should be on the module.
22 for value
in errno
.errorcode
.itervalues():
23 self
.assertTrue(hasattr(errno
, value
), 'no %s attr in errno' % value
)
26 class ErrorcodeTests(unittest
.TestCase
):
28 def test_attributes_in_errorcode(self
):
29 for attribute
in errno
.__dict
__.iterkeys():
30 if attribute
.isupper():
31 self
.assertIn(getattr(errno
, attribute
), errno
.errorcode
,
32 'no %s attr in errno.errorcode' % attribute
)
36 test_support
.run_unittest(ErrnoAttributeTests
, ErrorcodeTests
)
39 if __name__
== '__main__':