Mercurial > cpython-lru_cache-weakref
annotate Lib/test/test_errno.py @ 5817:48b94de85bf3 legacy-trunk
Extensive changes by AMK.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Thu, 17 Jul 1997 16:29:42 +0000 |
| parents | a76a3a39f6bc |
| children | aedd2d0dcb31 |
| rev | line source |
|---|---|
|
4735
4a3f45b3471a
Added test_errno to the test suite
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff
changeset
|
1 #! /usr/bin/env python |
|
4a3f45b3471a
Added test_errno to the test suite
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff
changeset
|
2 """Test the errno module |
|
4a3f45b3471a
Added test_errno to the test suite
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff
changeset
|
3 Roger E. Masse |
|
4a3f45b3471a
Added test_errno to the test suite
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff
changeset
|
4 """ |
|
4740
062e88608b55
Revised test for errno ala bwarsaw's testing paradigm.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4735
diff
changeset
|
5 |
|
062e88608b55
Revised test for errno ala bwarsaw's testing paradigm.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4735
diff
changeset
|
6 import errno |
|
4811
9ae3cccfa7cd
Many scripts, but small changes. Update the way the scripts obtain the
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4740
diff
changeset
|
7 from test_support import verbose |
|
4735
4a3f45b3471a
Added test_errno to the test suite
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff
changeset
|
8 |
|
4a3f45b3471a
Added test_errno to the test suite
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff
changeset
|
9 errors = ['E2BIG', 'EACCES', 'EADDRINUSE', 'EADDRNOTAVAIL', 'EADV', |
|
4a3f45b3471a
Added test_errno to the test suite
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff
changeset
|
10 'EAFNOSUPPORT', 'EAGAIN', 'EALREADY', 'EBADE', 'EBADF', |
|
4a3f45b3471a
Added test_errno to the test suite
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff
changeset
|
11 'EBADFD', 'EBADMSG', 'EBADR', 'EBADRQC', 'EBADSLT', |
|
4a3f45b3471a
Added test_errno to the test suite
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff
changeset
|
12 'EBFONT', 'EBUSY', 'ECHILD', 'ECHRNG', 'ECOMM', |
|
4a3f45b3471a
Added test_errno to the test suite
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff
changeset
|
13 'ECONNABORTED', 'ECONNREFUSED', 'ECONNRESET', |
|
4a3f45b3471a
Added test_errno to the test suite
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff
changeset
|
14 'EDEADLK', 'EDEADLOCK', 'EDESTADDRREQ', 'EDOM', |
|
4a3f45b3471a
Added test_errno to the test suite
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff
changeset
|
15 'EDQUOT', 'EEXIST', 'EFAULT', 'EFBIG', 'EHOSTDOWN', |
|
4a3f45b3471a
Added test_errno to the test suite
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff
changeset
|
16 'EHOSTUNREACH', 'EIDRM', 'EILSEQ', 'EINPROGRESS', |
|
4a3f45b3471a
Added test_errno to the test suite
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff
changeset
|
17 'EINTR', 'EINVAL', 'EIO', 'EISCONN', 'EISDIR', |
|
4a3f45b3471a
Added test_errno to the test suite
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff
changeset
|
18 'EL2HLT', 'EL2NSYNC', 'EL3HLT', 'EL3RST', 'ELIBACC', |
|
4a3f45b3471a
Added test_errno to the test suite
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff
changeset
|
19 'ELIBBAD', 'ELIBEXEC', 'ELIBMAX', 'ELIBSCN', 'ELNRNG', |
|
4a3f45b3471a
Added test_errno to the test suite
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff
changeset
|
20 'ELOOP', 'EMFILE', 'EMLINK', 'EMSGSIZE', 'EMULTIHOP', |
|
4a3f45b3471a
Added test_errno to the test suite
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff
changeset
|
21 'ENAMETOOLONG', 'ENETDOWN', 'ENETRESET', 'ENETUNREACH', |
|
4a3f45b3471a
Added test_errno to the test suite
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff
changeset
|
22 'ENFILE', 'ENOANO', 'ENOBUFS', 'ENOCSI', 'ENODATA', |
|
4a3f45b3471a
Added test_errno to the test suite
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff
changeset
|
23 'ENODEV', 'ENOENT', 'ENOEXEC', 'ENOLCK', 'ENOLINK', |
|
4a3f45b3471a
Added test_errno to the test suite
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff
changeset
|
24 'ENOMEM', 'ENOMSG', 'ENONET', 'ENOPKG', 'ENOPROTOOPT', |
|
4a3f45b3471a
Added test_errno to the test suite
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff
changeset
|
25 'ENOSPC', 'ENOSR', 'ENOSTR', 'ENOSYS', 'ENOTBLK', |
|
5291
a76a3a39f6bc
Don't just die when an error is not defined; print a warning instead.
Guido van Rossum <guido@python.org>
parents:
4811
diff
changeset
|
26 'ENOTCONN', 'ENOTDIR', 'ENOTEMPTY', 'ENOTOBACCO', 'ENOTSOCK', |
|
4735
4a3f45b3471a
Added test_errno to the test suite
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff
changeset
|
27 'ENOTTY', 'ENOTUNIQ', 'ENXIO', 'EOPNOTSUPP', |
|
4a3f45b3471a
Added test_errno to the test suite
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff
changeset
|
28 'EOVERFLOW', 'EPERM', 'EPFNOSUPPORT', 'EPIPE', |
|
4a3f45b3471a
Added test_errno to the test suite
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff
changeset
|
29 'EPROTO', 'EPROTONOSUPPORT', 'EPROTOTYPE', |
|
4a3f45b3471a
Added test_errno to the test suite
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff
changeset
|
30 'ERANGE', 'EREMCHG', 'EREMOTE', 'ERESTART', |
|
4a3f45b3471a
Added test_errno to the test suite
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff
changeset
|
31 'EROFS', 'ESHUTDOWN', 'ESOCKTNOSUPPORT', 'ESPIPE', |
|
4a3f45b3471a
Added test_errno to the test suite
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff
changeset
|
32 'ESRCH', 'ESRMNT', 'ESTALE', 'ESTRPIPE', 'ETIME', |
|
4a3f45b3471a
Added test_errno to the test suite
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff
changeset
|
33 'ETIMEDOUT', 'ETOOMANYREFS', 'ETXTBSY', 'EUNATCH', |
|
4a3f45b3471a
Added test_errno to the test suite
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff
changeset
|
34 'EUSERS', 'EWOULDBLOCK', 'EXDEV', 'EXFULL'] |
|
4a3f45b3471a
Added test_errno to the test suite
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff
changeset
|
35 |
|
4a3f45b3471a
Added test_errno to the test suite
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff
changeset
|
36 # |
|
4811
9ae3cccfa7cd
Many scripts, but small changes. Update the way the scripts obtain the
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4740
diff
changeset
|
37 # This is is a wee bit bogus since the module only conditionally adds |
|
4735
4a3f45b3471a
Added test_errno to the test suite
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff
changeset
|
38 # errno constants if they have been defined by errno.h However, this |
|
4a3f45b3471a
Added test_errno to the test suite
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff
changeset
|
39 # test seems to work on SGI, Sparc & intel Solaris, and linux. |
|
4a3f45b3471a
Added test_errno to the test suite
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff
changeset
|
40 # |
|
4a3f45b3471a
Added test_errno to the test suite
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff
changeset
|
41 for error in errors: |
|
5291
a76a3a39f6bc
Don't just die when an error is not defined; print a warning instead.
Guido van Rossum <guido@python.org>
parents:
4811
diff
changeset
|
42 try: |
|
a76a3a39f6bc
Don't just die when an error is not defined; print a warning instead.
Guido van Rossum <guido@python.org>
parents:
4811
diff
changeset
|
43 a = getattr(errno, error) |
|
a76a3a39f6bc
Don't just die when an error is not defined; print a warning instead.
Guido van Rossum <guido@python.org>
parents:
4811
diff
changeset
|
44 except AttributeError: |
|
a76a3a39f6bc
Don't just die when an error is not defined; print a warning instead.
Guido van Rossum <guido@python.org>
parents:
4811
diff
changeset
|
45 if verbose: |
|
a76a3a39f6bc
Don't just die when an error is not defined; print a warning instead.
Guido van Rossum <guido@python.org>
parents:
4811
diff
changeset
|
46 print '%s: not found' % error |
|
a76a3a39f6bc
Don't just die when an error is not defined; print a warning instead.
Guido van Rossum <guido@python.org>
parents:
4811
diff
changeset
|
47 else: |
|
a76a3a39f6bc
Don't just die when an error is not defined; print a warning instead.
Guido van Rossum <guido@python.org>
parents:
4811
diff
changeset
|
48 if verbose: |
|
a76a3a39f6bc
Don't just die when an error is not defined; print a warning instead.
Guido van Rossum <guido@python.org>
parents:
4811
diff
changeset
|
49 print '%s: %d' % (error, a) |
