summaryrefslogtreecommitdiff
path: root/testing
diff options
context:
space:
mode:
authorBruno Oliveira <nicoddemus@gmail.com>2019-11-13 17:51:14 -0300
committerBruno Oliveira <nicoddemus@gmail.com>2019-11-13 19:57:10 -0300
commit6f2c0fd2e8e8154c8129900c9a1c650068811404 (patch)
tree9e9cd71621ce9fc802bea25eaa0367438fd65a12 /testing
parent55a58bcd3d15887610e1303f4076401bd16ba742 (diff)
downloadpytest-6f2c0fd2e8e8154c8129900c9a1c650068811404.tar.gz
Show a better message when 'request' is used in parametrize
Fix #6183
Diffstat (limited to 'testing')
-rw-r--r--testing/python/metafunc.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/testing/python/metafunc.py b/testing/python/metafunc.py
index 5becb0f8c..860b21ff2 100644
--- a/testing/python/metafunc.py
+++ b/testing/python/metafunc.py
@@ -72,6 +72,19 @@ class TestMetafunc:
):
metafunc.parametrize("x", [1], scope="doggy")
+ def test_parametrize_request_name(self, testdir):
+ """Show proper error when 'request' is used as a parameter name in parametrize (#6183)"""
+
+ def func(request):
+ raise NotImplementedError()
+
+ metafunc = self.Metafunc(func)
+ with pytest.raises(
+ pytest.fail.Exception,
+ match=r"'request' is a reserved name and cannot be used in @pytest.mark.parametrize",
+ ):
+ metafunc.parametrize("request", [1])
+
def test_find_parametrized_scope(self):
"""unittest for _find_parametrized_scope (#3941)"""
from _pytest.python import _find_parametrized_scope