~ubuntu-branches/ubuntu/maverick/python3.1/maverick

« back to all changes in this revision

Viewing changes to Lib/test/test_errno.py

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2009-03-23 00:01:27 UTC
  • Revision ID: james.westby@ubuntu.com-20090323000127-5fstfxju4ufrhthq
Tags: upstream-3.1~a1+20090322
ImportĀ upstreamĀ versionĀ 3.1~a1+20090322

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /usr/bin/env python
 
2
"""Test the errno module
 
3
   Roger E. Masse
 
4
"""
 
5
 
 
6
import errno
 
7
from test import support
 
8
import unittest
 
9
 
 
10
std_c_errors = frozenset(['EDOM', 'ERANGE'])
 
11
 
 
12
class ErrnoAttributeTests(unittest.TestCase):
 
13
 
 
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.assert_(hasattr(errno, error_code),
 
18
                            "errno is missing %s" % error_code)
 
19
 
 
20
    def test_using_errorcode(self):
 
21
        # Every key value in errno.errorcode should be on the module.
 
22
        for value in errno.errorcode.values():
 
23
            self.assert_(hasattr(errno, value), 'no %s attr in errno' % value)
 
24
 
 
25
 
 
26
class ErrorcodeTests(unittest.TestCase):
 
27
 
 
28
    def test_attributes_in_errorcode(self):
 
29
        for attribute in errno.__dict__.keys():
 
30
            if attribute.isupper():
 
31
                self.assert_(getattr(errno, attribute) in errno.errorcode,
 
32
                             'no %s attr in errno.errorcode' % attribute)
 
33
 
 
34
 
 
35
def test_main():
 
36
    support.run_unittest(ErrnoAttributeTests, ErrorcodeTests)
 
37
 
 
38
 
 
39
if __name__ == '__main__':
 
40
    test_main()