equal
deleted
inserted
replaced
|
1 from test.test_support import verbose, TestFailed, TestSkipped |
|
2 import nis |
|
3 |
|
4 print 'nis.maps()' |
|
5 try: |
|
6 maps = nis.maps() |
|
7 except nis.error, msg: |
|
8 # NIS is probably not active, so this test isn't useful |
|
9 if verbose: |
|
10 raise TestFailed, msg |
|
11 # only do this if running under the regression suite |
|
12 raise TestSkipped, msg |
|
13 |
|
14 try: |
|
15 # On some systems, this map is only accessible to the |
|
16 # super user |
|
17 maps.remove("passwd.adjunct.byname") |
|
18 except ValueError: |
|
19 pass |
|
20 |
|
21 done = 0 |
|
22 for nismap in maps: |
|
23 if verbose: |
|
24 print nismap |
|
25 mapping = nis.cat(nismap) |
|
26 for k, v in mapping.items(): |
|
27 if verbose: |
|
28 print ' ', k, v |
|
29 if not k: |
|
30 continue |
|
31 if nis.match(k, nismap) != v: |
|
32 print "NIS match failed for key `%s' in map `%s'" % (k, nismap) |
|
33 else: |
|
34 # just test the one key, otherwise this test could take a |
|
35 # very long time |
|
36 done = 1 |
|
37 break |
|
38 if done: |
|
39 break |