diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 05c868079..6eae9b1d1 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -65,6 +65,9 @@ Changes * Add ``venv`` to the default ``norecursedirs`` setting. Thanks `@The-Compiler`_ for the PR. + +* ``PluginManager.import_plugin`` now accepts unicode plugin names in Python 2. + Thanks `@reutsharabani`_ for the PR. Bug Fixes @@ -82,6 +85,7 @@ Bug Fixes .. _@fogo: https://github.com/fogo .. _@mandeep: https://github.com/mandeep .. _@MichalTHEDUDE: https://github.com/MichalTHEDUDE +.. _@reutsharabani: https://github.com/reutsharabani .. _@unsignedint: https://github.com/unsignedint .. _@Kriechi: https://github.com/Kriechi diff --git a/_pytest/config.py b/_pytest/config.py index db37280ca..306d9a123 100644 --- a/_pytest/config.py +++ b/_pytest/config.py @@ -415,7 +415,8 @@ class PytestPluginManager(PluginManager): # "terminal" or "capture". Those plugins are registered under their # basename for historic purposes but must be imported with the # _pytest prefix. - assert isinstance(modname, str), "module name as string required, got %r" % modname + assert isinstance(modname, (py.builtin.text, str)), "module name as text required, got %r" % modname + modname = str(modname) if self.get_plugin(modname) is not None: return if modname in builtin_plugins: diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index fe02d82f0..85dd83969 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -793,3 +793,17 @@ def test_zipimport_hook(testdir, tmpdir): assert result.ret == 0 result.stderr.fnmatch_lines(['*not found*foo*']) assert 'INTERNALERROR>' not in result.stdout.str() + + +def test_import_plugin_unicode_name(testdir): + testdir.makepyfile( + myplugin='', + ) + testdir.makepyfile(""" + def test(): pass + """) + testdir.makeconftest(""" + pytest_plugins = [u'myplugin'] + """) + r = testdir.runpytest() + assert r.ret == 0