Merge pull request #2347 from reutsharabani/features

added option to unicode plugin name
This commit is contained in:
Ronny Pfannschmidt 2017-04-06 18:16:20 +02:00 committed by GitHub
commit 83b241b449
3 changed files with 20 additions and 1 deletions

View File

@ -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

View File

@ -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:

View File

@ -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