Mercurial > cpython-lru_cache-weakref
annotate Lib/test/test_nis.py @ 54294:dba767bc3155 legacy-trunk
remove mention of old ctypes version
| author | Benjamin Peterson <benjamin@python.org> |
|---|---|
| date | Sat, 23 May 2009 20:59:09 +0000 |
| parents | f4c5e3a64be2 |
| children |
| rev | line source |
|---|---|
|
45925
8817a8e12a55
test_nis would fail if test.test_support.verbose was true but NIS was not set
Brett Cannon <bcannon@gmail.com>
parents:
40261
diff
changeset
|
1 from test import test_support |
|
40261
7ce872bf00a3
Convert test_nis to unittest.
Georg Brandl <georg@python.org>
parents:
40164
diff
changeset
|
2 import unittest |
|
52491
f4c5e3a64be2
Change more tests to use import_module for the modules that
R. David Murray <rdmurray@bitdance.com>
parents:
52353
diff
changeset
|
3 |
|
f4c5e3a64be2
Change more tests to use import_module for the modules that
R. David Murray <rdmurray@bitdance.com>
parents:
52353
diff
changeset
|
4 nis = test_support.import_module('nis') |
| 4678 | 5 |
|
40261
7ce872bf00a3
Convert test_nis to unittest.
Georg Brandl <georg@python.org>
parents:
40164
diff
changeset
|
6 class NisTests(unittest.TestCase): |
|
7ce872bf00a3
Convert test_nis to unittest.
Georg Brandl <georg@python.org>
parents:
40164
diff
changeset
|
7 def test_maps(self): |
|
7ce872bf00a3
Convert test_nis to unittest.
Georg Brandl <georg@python.org>
parents:
40164
diff
changeset
|
8 try: |
|
7ce872bf00a3
Convert test_nis to unittest.
Georg Brandl <georg@python.org>
parents:
40164
diff
changeset
|
9 maps = nis.maps() |
|
7ce872bf00a3
Convert test_nis to unittest.
Georg Brandl <georg@python.org>
parents:
40164
diff
changeset
|
10 except nis.error, msg: |
|
7ce872bf00a3
Convert test_nis to unittest.
Georg Brandl <georg@python.org>
parents:
40164
diff
changeset
|
11 # NIS is probably not active, so this test isn't useful |
|
45925
8817a8e12a55
test_nis would fail if test.test_support.verbose was true but NIS was not set
Brett Cannon <bcannon@gmail.com>
parents:
40261
diff
changeset
|
12 if test_support.verbose: |
|
8817a8e12a55
test_nis would fail if test.test_support.verbose was true but NIS was not set
Brett Cannon <bcannon@gmail.com>
parents:
40261
diff
changeset
|
13 print "Test Skipped:", msg |
|
52353
e6009b9cd908
remove test_support.TestSkipped and just use unittest.SkipTest
Benjamin Peterson <benjamin@python.org>
parents:
45925
diff
changeset
|
14 # Can't raise SkipTest as regrtest only recognizes the exception |
|
45925
8817a8e12a55
test_nis would fail if test.test_support.verbose was true but NIS was not set
Brett Cannon <bcannon@gmail.com>
parents:
40261
diff
changeset
|
15 # import time. |
|
40261
7ce872bf00a3
Convert test_nis to unittest.
Georg Brandl <georg@python.org>
parents:
40164
diff
changeset
|
16 return |
|
7ce872bf00a3
Convert test_nis to unittest.
Georg Brandl <georg@python.org>
parents:
40164
diff
changeset
|
17 try: |
|
7ce872bf00a3
Convert test_nis to unittest.
Georg Brandl <georg@python.org>
parents:
40164
diff
changeset
|
18 # On some systems, this map is only accessible to the |
|
7ce872bf00a3
Convert test_nis to unittest.
Georg Brandl <georg@python.org>
parents:
40164
diff
changeset
|
19 # super user |
|
7ce872bf00a3
Convert test_nis to unittest.
Georg Brandl <georg@python.org>
parents:
40164
diff
changeset
|
20 maps.remove("passwd.adjunct.byname") |
|
7ce872bf00a3
Convert test_nis to unittest.
Georg Brandl <georg@python.org>
parents:
40164
diff
changeset
|
21 except ValueError: |
|
7ce872bf00a3
Convert test_nis to unittest.
Georg Brandl <georg@python.org>
parents:
40164
diff
changeset
|
22 pass |
|
40164
749d855ee357
Remove passwd.adjunct.byname from list of maps
Martin v. Löwis <martin@v.loewis.de>
parents:
24364
diff
changeset
|
23 |
|
40261
7ce872bf00a3
Convert test_nis to unittest.
Georg Brandl <georg@python.org>
parents:
40164
diff
changeset
|
24 done = 0 |
|
7ce872bf00a3
Convert test_nis to unittest.
Georg Brandl <georg@python.org>
parents:
40164
diff
changeset
|
25 for nismap in maps: |
|
7ce872bf00a3
Convert test_nis to unittest.
Georg Brandl <georg@python.org>
parents:
40164
diff
changeset
|
26 mapping = nis.cat(nismap) |
|
7ce872bf00a3
Convert test_nis to unittest.
Georg Brandl <georg@python.org>
parents:
40164
diff
changeset
|
27 for k, v in mapping.items(): |
|
7ce872bf00a3
Convert test_nis to unittest.
Georg Brandl <georg@python.org>
parents:
40164
diff
changeset
|
28 if not k: |
|
7ce872bf00a3
Convert test_nis to unittest.
Georg Brandl <georg@python.org>
parents:
40164
diff
changeset
|
29 continue |
|
7ce872bf00a3
Convert test_nis to unittest.
Georg Brandl <georg@python.org>
parents:
40164
diff
changeset
|
30 if nis.match(k, nismap) != v: |
|
7ce872bf00a3
Convert test_nis to unittest.
Georg Brandl <georg@python.org>
parents:
40164
diff
changeset
|
31 self.fail("NIS match failed for key `%s' in map `%s'" % (k, nismap)) |
|
7ce872bf00a3
Convert test_nis to unittest.
Georg Brandl <georg@python.org>
parents:
40164
diff
changeset
|
32 else: |
|
7ce872bf00a3
Convert test_nis to unittest.
Georg Brandl <georg@python.org>
parents:
40164
diff
changeset
|
33 # just test the one key, otherwise this test could take a |
|
7ce872bf00a3
Convert test_nis to unittest.
Georg Brandl <georg@python.org>
parents:
40164
diff
changeset
|
34 # very long time |
|
7ce872bf00a3
Convert test_nis to unittest.
Georg Brandl <georg@python.org>
parents:
40164
diff
changeset
|
35 done = 1 |
|
7ce872bf00a3
Convert test_nis to unittest.
Georg Brandl <georg@python.org>
parents:
40164
diff
changeset
|
36 break |
|
7ce872bf00a3
Convert test_nis to unittest.
Georg Brandl <georg@python.org>
parents:
40164
diff
changeset
|
37 if done: |
|
7ce872bf00a3
Convert test_nis to unittest.
Georg Brandl <georg@python.org>
parents:
40164
diff
changeset
|
38 break |
|
7ce872bf00a3
Convert test_nis to unittest.
Georg Brandl <georg@python.org>
parents:
40164
diff
changeset
|
39 |
|
7ce872bf00a3
Convert test_nis to unittest.
Georg Brandl <georg@python.org>
parents:
40164
diff
changeset
|
40 def test_main(): |
|
45925
8817a8e12a55
test_nis would fail if test.test_support.verbose was true but NIS was not set
Brett Cannon <bcannon@gmail.com>
parents:
40261
diff
changeset
|
41 test_support.run_unittest(NisTests) |
|
40261
7ce872bf00a3
Convert test_nis to unittest.
Georg Brandl <georg@python.org>
parents:
40164
diff
changeset
|
42 |
|
7ce872bf00a3
Convert test_nis to unittest.
Georg Brandl <georg@python.org>
parents:
40164
diff
changeset
|
43 if __name__ == '__main__': |
|
7ce872bf00a3
Convert test_nis to unittest.
Georg Brandl <georg@python.org>
parents:
40164
diff
changeset
|
44 test_main() |
