ยปCore Development>Code coverage>Lib/test/test_nis.py

Python code coverage for Lib/test/test_nis.py

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