Fix an amazing number of typos & malformed sentences reported by Detlef
[python/dscho.git] / Lib / test / test_nis.py
blobb73faf9e89774cbaf7d9645a6afc83290d701a3a
1 from test_support import verbose, TestFailed
2 import nis
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 ImportError, msg
14 done = 0
15 for nismap in maps:
16 if verbose:
17 print nismap
18 mapping = nis.cat(nismap)
19 for k, v in mapping.items():
20 if verbose:
21 print ' ', k, v
22 if not k:
23 continue
24 if nis.match(k, nismap) <> v:
25 print "NIS match failed for key `%s' in map `%s'" % (k, nismap)
26 else:
27 # just test the one key, otherwise this test could take a
28 # very long time
29 done = 1
30 break
31 if done:
32 break