| 1 |
from test import support |
| 2 |
from test.support import import_helper |
| 3 |
import unittest |
| 4 |
import warnings |
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
with warnings.catch_warnings(): |
| 9 |
warnings.simplefilter("ignore", DeprecationWarning) |
| 10 |
nis = import_helper.import_module('nis') |
| 11 |
|
| 12 |
|
| 13 |
class NisTests(unittest.TestCase): |
| 14 |
def test_maps(self): |
| 15 |
try: |
| 16 |
maps = nis.maps() |
| 17 |
except nis.error as msg: |
| 18 |
|
| 19 |
self.skipTest(str(msg)) |
| 20 |
try: |
| 21 |
|
| 22 |
|
| 23 |
maps.remove("passwd.adjunct.byname") |
| 24 |
except ValueError: |
| 25 |
pass |
| 26 |
|
| 27 |
done = 0 |
| 28 |
for nismap in maps: |
| 29 |
mapping = nis.cat(nismap) |
| 30 |
for k, v in mapping.items(): |
| 31 |
if not k: |
| 32 |
continue |
| 33 |
if nis.match(k, nismap) != v: |
| 34 |
self.fail("NIS match failed for key `%s' in map `%s'" % (k, nismap)) |
| 35 |
else: |
| 36 |
|
| 37 |
|
| 38 |
done = 1 |
| 39 |
break |
| 40 |
if done: |
| 41 |
break |
| 42 |
|
| 43 |
if __name__ == '__main__': |
| 44 |
unittest.main() |