Clarify portability and main program.
[python/dscho.git] / Lib / test / test_nis.py
blobb28a6722d2bce8214b31b24b814c5d3ab995847c
1 from test_support import verbose, TestFailed
2 import nis
4 print 'nis.maps()'
5 try:
6 # the following could fail if NIS isn't active
7 maps = nis.maps()
8 except nis.error, msg:
9 raise TestFailed, msg
11 done = 0
12 for nismap in maps:
13 if verbose:
14 print nismap
15 mapping = nis.cat(nismap)
16 for k, v in mapping.items():
17 if verbose:
18 print ' ', k, v
19 if not k:
20 continue
21 if nis.match(k, nismap) <> v:
22 print "NIS match failed for key `%s' in map `%s'" % (k, nismap)
23 else:
24 # just test the one key, otherwise this test could take a
25 # very long time
26 done = 1
27 break
28 if done:
29 break