diff options
| author | robot-contrib <[email protected]> | 2023-10-19 17:11:31 +0300 |
|---|---|---|
| committer | robot-contrib <[email protected]> | 2023-10-19 18:26:04 +0300 |
| commit | b9fe236a503791a3a7b37d4ef5f466225218996c (patch) | |
| tree | c2f80019399b393ddf0450d0f91fc36478af8bea /contrib/python/traitlets/py3/tests/utils/test_importstring.py | |
| parent | 44dd27d0a2ae37c80d97a95581951d1d272bd7df (diff) | |
Update contrib/python/traitlets/py3 to 5.11.2
Diffstat (limited to 'contrib/python/traitlets/py3/tests/utils/test_importstring.py')
| -rw-r--r-- | contrib/python/traitlets/py3/tests/utils/test_importstring.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/contrib/python/traitlets/py3/tests/utils/test_importstring.py b/contrib/python/traitlets/py3/tests/utils/test_importstring.py new file mode 100644 index 00000000000..8ce28add41e --- /dev/null +++ b/contrib/python/traitlets/py3/tests/utils/test_importstring.py @@ -0,0 +1,26 @@ +# Copyright (c) IPython Development Team. +# Distributed under the terms of the Modified BSD License. +# +# Adapted from enthought.traits, Copyright (c) Enthought, Inc., +# also under the terms of the Modified BSD License. +"""Tests for traitlets.utils.importstring.""" + +import os +from unittest import TestCase + +from traitlets.utils.importstring import import_item + + +class TestImportItem(TestCase): + def test_import_unicode(self): + self.assertIs(os, import_item("os")) + self.assertIs(os.path, import_item("os.path")) + self.assertIs(os.path.join, import_item("os.path.join")) + + def test_bad_input(self): + class NotAString: + pass + + msg = "import_item accepts strings, not '%s'." % NotAString + with self.assertRaisesRegex(TypeError, msg): + import_item(NotAString()) # type:ignore[arg-type] |
