blob: 1c17a4ee3b9e47412e57b14418a9fdca799cf5e6 [file] [log] [blame]
Benjamin Petersonee8712c2008-05-20 21:35:26 +00001from test import support
Thomas Wouters89f507f2006-12-13 04:49:30 +00002import unittest
Barry Warsaw3236b331996-12-11 01:01:38 +00003import nis
4
Benjamin Petersone9ea19e2008-08-19 23:02:38 +00005raise support.TestSkipped("test_nis hangs on Solaris")
6
Thomas Wouters89f507f2006-12-13 04:49:30 +00007class NisTests(unittest.TestCase):
8 def test_maps(self):
9 try:
10 maps = nis.maps()
Guido van Rossumb940e112007-01-10 16:19:56 +000011 except nis.error as msg:
Thomas Wouters89f507f2006-12-13 04:49:30 +000012 # NIS is probably not active, so this test isn't useful
Benjamin Petersonee8712c2008-05-20 21:35:26 +000013 if support.verbose:
Christian Heimesd5e2b6f2008-03-19 21:50:51 +000014 print("Test Skipped:", msg)
15 # Can't raise TestSkipped as regrtest only recognizes the exception
16 # import time.
Thomas Wouters89f507f2006-12-13 04:49:30 +000017 return
18 try:
19 # On some systems, this map is only accessible to the
20 # super user
21 maps.remove("passwd.adjunct.byname")
22 except ValueError:
23 pass
Barry Warsaw4c4d5ce1997-05-15 18:27:49 +000024
Thomas Wouters89f507f2006-12-13 04:49:30 +000025 done = 0
26 for nismap in maps:
27 mapping = nis.cat(nismap)
28 for k, v in mapping.items():
29 if not k:
30 continue
31 if nis.match(k, nismap) != v:
32 self.fail("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
40
41def test_main():
Benjamin Petersonee8712c2008-05-20 21:35:26 +000042 support.run_unittest(NisTests)
Thomas Wouters89f507f2006-12-13 04:49:30 +000043
44if __name__ == '__main__':
45 test_main()