test_importstring.py 654 B

123456789101112131415161718192021222324252627
  1. """Tests for IPython.utils.importstring."""
  2. # Copyright (c) IPython Development Team.
  3. # Distributed under the terms of the Modified BSD License.
  4. import nose.tools as nt
  5. from ..importstring import import_item
  6. def test_import_plain():
  7. "Test simple imports"
  8. import os
  9. os2 = import_item('os')
  10. nt.assert_true(os is os2)
  11. def test_import_nested():
  12. "Test nested imports from the stdlib"
  13. from os import path
  14. path2 = import_item('os.path')
  15. nt.assert_true(path is path2)
  16. def test_import_raises():
  17. "Test that failing imports raise the right exception"
  18. nt.assert_raises(ImportError, import_item, 'IPython.foobar')