mirror of
https://github.com/python/cpython.git
synced 2024-11-25 10:54:51 +08:00
a21e4ca3c6
........ r70734 | r.david.murray | 2009-03-30 15:04:00 -0400 (Mon, 30 Mar 2009) | 7 lines Add import_function method to test.test_support, and modify a number of tests that expect to be skipped if imports fail or functions don't exist to use import_function and import_module. The ultimate goal is to change regrtest to not skip automatically on ImportError. Checking in now to make sure the buldbots don't show any errors on platforms I can't direct test on. ........ r70775 | r.david.murray | 2009-03-30 19:05:48 -0400 (Mon, 30 Mar 2009) | 4 lines Change more tests to use import_module for the modules that should cause tests to be skipped. Also rename import_function to the more descriptive get_attribute and add a docstring. ........ r70856 | r.david.murray | 2009-03-31 14:32:17 -0400 (Tue, 31 Mar 2009) | 7 lines A few more test skips via import_module, and change import_module to return the error message produced by importlib, so that if an import in the package whose import is being wrapped is what failed the skip message will contain the name of that module instead of the name of the wrapped module. Also fixed formatting of some previous comments. ........ r70874 | r.david.murray | 2009-03-31 15:33:15 -0400 (Tue, 31 Mar 2009) | 5 lines Improve test_support.import_module docstring, remove deprecated flag from get_attribute since it isn't likely to do anything useful. ........ r70876 | r.david.murray | 2009-03-31 15:49:15 -0400 (Tue, 31 Mar 2009) | 4 lines Remove the regrtest check that turns any ImportError into a skipped test. Hopefully all modules whose imports legitimately result in a skipped test have been properly wrapped by the previous commits. ........ r70877 | r.david.murray | 2009-03-31 15:57:24 -0400 (Tue, 31 Mar 2009) | 2 lines Add NEWS entry for regrtest change. ........
48 lines
1.4 KiB
Python
48 lines
1.4 KiB
Python
from test import support
|
|
import unittest
|
|
|
|
# Skip test if nis module does not exist.
|
|
nis = support.import_module('nis')
|
|
|
|
raise unittest.SkipTest("test_nis hangs on Solaris")
|
|
|
|
class NisTests(unittest.TestCase):
|
|
def test_maps(self):
|
|
try:
|
|
maps = nis.maps()
|
|
except nis.error as msg:
|
|
# NIS is probably not active, so this test isn't useful
|
|
if support.verbose:
|
|
print("Test Skipped:", msg)
|
|
# Can't raise SkipTest as regrtest only recognizes the exception
|
|
# import time.
|
|
return
|
|
try:
|
|
# On some systems, this map is only accessible to the
|
|
# super user
|
|
maps.remove("passwd.adjunct.byname")
|
|
except ValueError:
|
|
pass
|
|
|
|
done = 0
|
|
for nismap in maps:
|
|
mapping = nis.cat(nismap)
|
|
for k, v in mapping.items():
|
|
if not k:
|
|
continue
|
|
if nis.match(k, nismap) != v:
|
|
self.fail("NIS match failed for key `%s' in map `%s'" % (k, nismap))
|
|
else:
|
|
# just test the one key, otherwise this test could take a
|
|
# very long time
|
|
done = 1
|
|
break
|
|
if done:
|
|
break
|
|
|
|
def test_main():
|
|
support.run_unittest(NisTests)
|
|
|
|
if __name__ == '__main__':
|
|
test_main()
|