@@ -84,6 +84,29 @@ def test_foo(check_first):
8484 assert 0
8585 result .stdout .fnmatch_lines ([expected ])
8686
87+ @pytest .mark .parametrize ('mode' , ['str' , 'list' ])
88+ def test_pytest_plugins_rewrite_module_names (self , testdir , mode ):
89+ """Test that pluginmanager correct marks pytest_plugins variables
90+ for assertion rewriting if they are defined as plain strings or
91+ list of strings (#1888).
92+ """
93+ plugins = '"ham"' if mode == 'str' else '["ham"]'
94+ contents = {
95+ 'conftest.py' : """
96+ pytest_plugins = {plugins}
97+ """ .format (plugins = plugins ),
98+ 'ham.py' : """
99+ import pytest
100+ """ ,
101+ 'test_foo.py' : """
102+ def test_foo(pytestconfig):
103+ assert 'ham' in pytestconfig.pluginmanager.rewrite_hook._must_rewrite
104+ """ ,
105+ }
106+ testdir .makepyfile (** contents )
107+ result = testdir .runpytest_subprocess ('--assert=rewrite' )
108+ assert result .ret == 0
109+
87110 @pytest .mark .parametrize ('mode' , ['plain' , 'rewrite' ])
88111 def test_installed_plugin_rewrite (self , testdir , mode ):
89112 # Make sure the hook is installed early enough so that plugins
@@ -196,6 +219,12 @@ def test_other():
196219 '>*assert l.pop() == 3*' ,
197220 'E*AssertionError' ])
198221
222+ def test_register_assert_rewrite_checks_types (self ):
223+ with pytest .raises (TypeError ):
224+ pytest .register_assert_rewrite (['pytest_tests_internal_non_existing' ])
225+ pytest .register_assert_rewrite ('pytest_tests_internal_non_existing' ,
226+ 'pytest_tests_internal_non_existing2' )
227+
199228
200229class TestBinReprIntegration :
201230
0 commit comments