home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / pyos2bin.zip / Lib / test / test_nis.py < prev    next >
Text File  |  1997-05-15  |  626b  |  30 lines

  1. from test_support import verbose, TestFailed
  2. import nis
  3.  
  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 
  10.  
  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
  30.