home *** CD-ROM | disk | FTP | other *** search
/ PC World 2001 April / PCWorld_2001-04_cd.bin / Software / TemaCD / webclean / !!!python!!! / BeOpen-Python-2.0.exe / TEST_NIS.PY < prev    next >
Encoding:
Python Source  |  2000-09-28  |  874 b   |  33 lines

  1. from 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. 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
  33.