You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ORPA-pyOpenRPA/Resources/LPy64-3105/lib/python3.10/site-packages/traitlets/utils/tests/test_importstring.py

27 lines
814 B

# 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 ..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())