Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove import of pkg_resources for parsing pytest version #826

Merged
merged 1 commit into from
Mar 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions pytest_django/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import types

import pytest
from pkg_resources import parse_version

from .django_compat import is_django_unittest # noqa
from .fixtures import django_assert_num_queries # noqa
Expand Down Expand Up @@ -53,7 +52,8 @@
PY2 = sys.version_info[0] == 2

# pytest 4.2 handles unittest setup/teardown itself via wrapping fixtures.
_handle_unittest_methods = parse_version(pytest.__version__) < parse_version("4.2")
_pytest_version_info = tuple(int(x) for x in pytest.__version__.split(".", 2)[:2])
_handle_unittest_methods = _pytest_version_info < (4, 2)

_report_header = []

Expand Down
4 changes: 2 additions & 2 deletions tests/test_unittest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest
from django.test import TestCase
from pkg_resources import parse_version

from pytest_django.plugin import _pytest_version_info
from pytest_django_test.app.models import Item


Expand Down Expand Up @@ -146,7 +146,7 @@ def test_pass(self):
expected_lines = [
"* ERROR at setup of TestFoo.test_pass *",
]
if parse_version(pytest.__version__) < parse_version("4.2"):
if _pytest_version_info < (4, 2):
expected_lines += [
"E *Failed: <class 'tpkg.test_the_test.TestFoo'>.setUpClass should be a classmethod", # noqa:E501
]
Expand Down