diff --git a/tests/test_app.py b/tests/test_app.py index 9636b75..6ab109a 100644 --- a/tests/test_app.py +++ b/tests/test_app.py @@ -698,3 +698,9 @@ def test_xhr_param_change_headers(self): resp.charset = 'ascii' self.assertIn('HTTP_X_REQUESTED_WITH: XMLHttpRequest', resp.text) + + +class TestRequest(unittest.TestCase): + + def test_pytest_collection_disabled(self): + self.assertFalse(webtest.TestRequest.__test__) diff --git a/tests/test_response.py b/tests/test_response.py index aa1cb1d..5504173 100644 --- a/tests/test_response.py +++ b/tests/test_response.py @@ -492,3 +492,6 @@ def test_maybe_follow_twice(self): def test_maybe_follow_infinite(self): app = self.get_redirects_app(100000) self.assertRaises(AssertionError, app.get('/').maybe_follow) + + def test_pytest_collection_disabled(self): + self.assertFalse(webtest.TestResponse.__test__) diff --git a/webtest/app.py b/webtest/app.py index 9e3155e..9304288 100644 --- a/webtest/app.py +++ b/webtest/app.py @@ -76,6 +76,10 @@ def set_ok_domain(self, cookie, request): class TestRequest(webob.BaseRequest): """A subclass of webob.Request""" + + # Tell pytest not to collect this class as tests + __test__ = False + ResponseClass = TestResponse diff --git a/webtest/response.py b/webtest/response.py index fea35aa..c69cad7 100644 --- a/webtest/response.py +++ b/webtest/response.py @@ -22,6 +22,9 @@ class TestResponse(webob.Response): _forms_indexed = None parser_features = 'html.parser' + # Tell pytest not to collect this class as tests + __test__ = False + @property def forms(self): """