| 1 | n/a | from . import util |
|---|
| 2 | n/a | import unittest |
|---|
| 3 | n/a | |
|---|
| 4 | n/a | |
|---|
| 5 | n/a | class APITest(unittest.TestCase): |
|---|
| 6 | n/a | |
|---|
| 7 | n/a | """Test API-specific details for __import__ (e.g. raising the right |
|---|
| 8 | n/a | exception when passing in an int for the module name).""" |
|---|
| 9 | n/a | |
|---|
| 10 | n/a | def test_name_requires_rparition(self): |
|---|
| 11 | n/a | # Raise TypeError if a non-string is passed in for the module name. |
|---|
| 12 | n/a | with self.assertRaises(TypeError): |
|---|
| 13 | n/a | util.import_(42) |
|---|
| 14 | n/a | |
|---|
| 15 | n/a | def test_negative_level(self): |
|---|
| 16 | n/a | # Raise ValueError when a negative level is specified. |
|---|
| 17 | n/a | # PEP 328 did away with sys.module None entries and the ambiguity of |
|---|
| 18 | n/a | # absolute/relative imports. |
|---|
| 19 | n/a | with self.assertRaises(ValueError): |
|---|
| 20 | n/a | util.import_('os', globals(), level=-1) |
|---|
| 21 | n/a | |
|---|
| 22 | n/a | |
|---|
| 23 | n/a | def test_main(): |
|---|
| 24 | n/a | from test.support import run_unittest |
|---|
| 25 | n/a | run_unittest(APITest) |
|---|
| 26 | n/a | |
|---|
| 27 | n/a | |
|---|
| 28 | n/a | if __name__ == '__main__': |
|---|
| 29 | n/a | test_main() |
|---|