Debian Codegraph @

cpython27/Lib/test/test_nis.py

raw symbols SCIP
1 from test import test_support
2 import unittest
3
4 nis = test_support.import_module('nis')
5
6 class NisTests(unittest.TestCase):
7 def test_maps(self):
8 try:
9 maps = nis.maps()
10 except nis.error, msg:
11 # NIS is probably not active, so this test isn't useful
12 self.skipTest(str(msg))
13 try:
14 # On some systems, this map is only accessible to the
15 # super user
16 maps.remove("passwd.adjunct.byname")
17 except ValueError:
18 pass
19
20 done = 0
21 for nismap in maps:
22 mapping = nis.cat(nismap)
23 for k, v in mapping.items():
24 if not k:
25 continue
26 if nis.match(k, nismap) != v:
27 self.fail("NIS match failed for key `%s' in map `%s'" % (k, nismap))
28 else:
29 # just test the one key, otherwise this test could take a
30 # very long time
31 done = 1
32 break
33 if done:
34 break
35
36 def test_main():
37 test_support.run_unittest(NisTests)
38
39 if __name__ == '__main__':
40 test_main()