summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Chainz <adam@adamj.eu>2016-08-24 11:42:57 +0100
committerAdam Chainz <adam@adamj.eu>2016-08-24 11:49:14 +0100
commite3d70afbe7bfe5e021d7027f13cc32104b191a2f (patch)
treedd34df421af39852954b9aa9845ef6cd3ffe62e3
parentf43e53aba830e6b4b9ad8440af5e6c3992ee3347 (diff)
downloadraven-e3d70afbe7bfe5e021d7027f13cc32104b191a2f.tar.gz
Fix warnings from Pytest 3.0+
Fix WC1 warnings from the below: ``` ============================================================== pytest-warning summary ============================================================== WC1 None [pytest] section in setup.cfg files is deprecated, use [tool:pytest] instead. WI1 /Users/adamj/Documents/Projects/raven-python/.tox/py27/lib/python2.7/site-packages/pytest_timeout.py:68 'pytest_runtest_protocol' hook uses deprecated __multicall__ argument WC1 /Users/adamj/Documents/Projects/raven-python/tests/contrib/bottle/tests.py cannot collect test class 'TestApp' because it has a __init__ constructor WC1 /Users/adamj/Documents/Projects/raven-python/tests/contrib/django/tests.py cannot collect test class 'ClientHandler' because it has a __init__ constructor WC1 /Users/adamj/Documents/Projects/raven-python/tests/contrib/django/tests.py cannot collect test class 'Client' because it has a __init__ constructor WC1 /Users/adamj/Documents/Projects/raven-python/tests/contrib/django/tests.py cannot collect test class 'TestModel' because it has a __init__ constructor WC1 /Users/adamj/Documents/Projects/raven-python/tests/contrib/webpy/tests.py cannot collect test class 'TestApp' because it has a __init__ constructor ``` `setup.cfg` fixed as per pytest-dev/pytest#567. `cannot collect test class` fixed by renaming the affected class names so the collector doesn't consider them. The WI1 warning is left as it's in the `pytest_timeout` plugin.
-rw-r--r--setup.cfg2
-rw-r--r--tests/contrib/bottle/tests.py4
-rw-r--r--tests/contrib/django/models.py2
-rw-r--r--tests/contrib/django/tests.py16
-rw-r--r--tests/contrib/webpy/tests.py4
5 files changed, 14 insertions, 14 deletions
diff --git a/setup.cfg b/setup.cfg
index 3b8d262..5aecf85 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,4 +1,4 @@
-[pytest]
+[tool:pytest]
python_files=test*.py
addopts=--tb=native -p no:doctest
norecursedirs=bin dist docs htmlcov hooks node_modules .* {args}
diff --git a/tests/contrib/bottle/tests.py b/tests/contrib/bottle/tests.py
index 0813398..1c1da6e 100644
--- a/tests/contrib/bottle/tests.py
+++ b/tests/contrib/bottle/tests.py
@@ -1,6 +1,6 @@
from exam import fixture
-from webtest import TestApp
+from webtest import TestApp as WebtestApp # prevent pytest-warning
import bottle
@@ -25,7 +25,7 @@ def create_app(raven):
app = bottle.app()
app.catchall = False
app = Sentry(app, client=raven)
- tapp = TestApp(app)
+ tapp = WebtestApp(app)
@bottle.route('/error/', ['GET', 'POST'])
def an_error():
diff --git a/tests/contrib/django/models.py b/tests/contrib/django/models.py
index 06e03f2..d198cfd 100644
--- a/tests/contrib/django/models.py
+++ b/tests/contrib/django/models.py
@@ -3,5 +3,5 @@ from __future__ import absolute_import
from django.db import models
-class TestModel(models.Model):
+class MyTestModel(models.Model):
pass
diff --git a/tests/contrib/django/tests.py b/tests/contrib/django/tests.py
index 3aa6b74..66797e2 100644
--- a/tests/contrib/django/tests.py
+++ b/tests/contrib/django/tests.py
@@ -35,8 +35,8 @@ from raven.contrib.django.views import is_valid_origin
from raven.transport import HTTPTransport
from raven.utils.serializer import transform
-from django.test.client import Client as TestClient, ClientHandler as TestClientHandler
-from .models import TestModel
+from django.test.client import Client as DjangoTestClient, ClientHandler as DjangoTestClientHandler
+from .models import MyTestModel
settings.SENTRY_CLIENT = 'tests.contrib.django.tests.TempStoreClient'
@@ -55,7 +55,7 @@ def make_request():
})
-class MockClientHandler(TestClientHandler):
+class MockClientHandler(DjangoTestClientHandler):
def __call__(self, environ, start_response=[]):
# this pretends doesn't require start_response
return super(MockClientHandler, self).__call__(environ)
@@ -256,7 +256,7 @@ class DjangoClientTest(TestCase):
def test_broken_500_handler_with_middleware(self):
with Settings(BREAK_THAT_500=True, INSTALLED_APPS=['raven.contrib.django']):
- client = TestClient(REMOTE_ADDR='127.0.0.1')
+ client = DjangoTestClient(REMOTE_ADDR='127.0.0.1')
client.handler = MockSentryMiddleware(MockClientHandler())
self.assertRaises(Exception, client.get, reverse('sentry-raise-exc'))
@@ -733,21 +733,21 @@ class PromiseSerializerTestCase(TestCase):
class ModelInstanceSerializerTestCase(TestCase):
def test_basic(self):
- instance = TestModel()
+ instance = MyTestModel()
result = transform(instance)
assert isinstance(result, six.string_types)
- assert result == '<TestModel: TestModel object>'
+ assert result == '<MyTestModel: MyTestModel object>'
class QuerySetSerializerTestCase(TestCase):
def test_basic(self):
from django.db.models.query import QuerySet
- obj = QuerySet(model=TestModel)
+ obj = QuerySet(model=MyTestModel)
result = transform(obj)
assert isinstance(result, six.string_types)
- assert result == '<QuerySet: model=TestModel>'
+ assert result == '<QuerySet: model=MyTestModel>'
class SentryExceptionHandlerTest(TestCase):
diff --git a/tests/contrib/webpy/tests.py b/tests/contrib/webpy/tests.py
index d96cb9c..6082403 100644
--- a/tests/contrib/webpy/tests.py
+++ b/tests/contrib/webpy/tests.py
@@ -1,5 +1,5 @@
from exam import fixture
-from paste.fixture import TestApp
+from paste.fixture import TestApp as PasteTestApp # prevent pytest-warning
from raven.base import Client
from raven.contrib.webpy import SentryApplication
@@ -43,7 +43,7 @@ class WebPyTest(TestCase):
@fixture
def client(self):
- return TestApp(self.app.wsgifunc())
+ return PasteTestApp(self.app.wsgifunc())
def test_get(self):
resp = self.client.get('/test', expect_errors=True)