[8.0.x] Replace reorder-python-imports by isort due to black incompatibility (#11898)
Backport of #11896
This commit is contained in:
@@ -6,10 +6,11 @@ import time
|
||||
import warnings
|
||||
from unittest import mock
|
||||
|
||||
import pytest
|
||||
from py import error
|
||||
from py.path import local
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
def ignore_encoding_warning():
|
||||
@@ -1366,8 +1367,8 @@ class TestPOSIXLocalPath:
|
||||
assert realpath.basename == "file"
|
||||
|
||||
def test_owner(self, path1, tmpdir):
|
||||
from pwd import getpwuid # type:ignore[attr-defined]
|
||||
from grp import getgrgid # type:ignore[attr-defined]
|
||||
from pwd import getpwuid # type:ignore[attr-defined]
|
||||
|
||||
stat = path1.stat()
|
||||
assert stat.path == path1
|
||||
|
||||
@@ -23,7 +23,6 @@ from _pytest.pathlib import import_path
|
||||
from _pytest.pytester import LineMatcher
|
||||
from _pytest.pytester import Pytester
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from _pytest._code.code import _TracebackStyle
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
"""Reproduces issue #3774"""
|
||||
|
||||
from unittest import mock
|
||||
|
||||
import pytest
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
"""Skipping an entire subclass with unittest.skip() should *not* call setUp from a base class."""
|
||||
|
||||
import unittest
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
"""Skipping an entire subclass with unittest.skip() should *not* call setUpClass from a base class."""
|
||||
|
||||
import unittest
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
"""setUpModule is always called, even if all tests in the module are skipped"""
|
||||
|
||||
import unittest
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
from typing import List
|
||||
from unittest import IsolatedAsyncioTestCase
|
||||
|
||||
|
||||
teardowns: List[None] = []
|
||||
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
"""Issue #7110"""
|
||||
|
||||
import asyncio
|
||||
from typing import List
|
||||
|
||||
import asynctest
|
||||
|
||||
|
||||
teardowns: List[None] = []
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
"""Generate an executable with pytest runner embedded using PyInstaller."""
|
||||
|
||||
if __name__ == "__main__":
|
||||
import pytest
|
||||
import subprocess
|
||||
|
||||
import pytest
|
||||
|
||||
hidden = []
|
||||
for x in pytest.freeze_includes():
|
||||
hidden.extend(["--hidden-import", x])
|
||||
|
||||
@@ -5,6 +5,7 @@ pytest main().
|
||||
|
||||
if __name__ == "__main__":
|
||||
import sys
|
||||
|
||||
import pytest
|
||||
|
||||
sys.exit(pytest.main())
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
Called by tox.ini: uses the generated executable to run the tests in ./tests/
|
||||
directory.
|
||||
"""
|
||||
|
||||
if __name__ == "__main__":
|
||||
import os
|
||||
import sys
|
||||
|
||||
@@ -12,7 +12,6 @@ import pytest
|
||||
from _pytest._io import terminalwriter
|
||||
from _pytest.monkeypatch import MonkeyPatch
|
||||
|
||||
|
||||
# These tests were initially copied from py 1.8.1.
|
||||
|
||||
|
||||
|
||||
@@ -830,9 +830,10 @@ def test_live_logging_suspends_capture(
|
||||
We parametrize the test to also make sure _LiveLoggingStreamHandler works correctly if no capture manager plugin
|
||||
is installed.
|
||||
"""
|
||||
import logging
|
||||
import contextlib
|
||||
import logging
|
||||
from functools import partial
|
||||
|
||||
from _pytest.logging import _LiveLoggingStreamHandler
|
||||
|
||||
class MockCaptureManager:
|
||||
|
||||
@@ -42,9 +42,10 @@ class TestMockDecoration:
|
||||
assert values == ("x",)
|
||||
|
||||
def test_getfuncargnames_patching(self):
|
||||
from _pytest.compat import getfuncargnames
|
||||
from unittest.mock import patch
|
||||
|
||||
from _pytest.compat import getfuncargnames
|
||||
|
||||
class T:
|
||||
def original(self, x, y, z):
|
||||
pass
|
||||
|
||||
@@ -1036,8 +1036,8 @@ class TestAssertionRewriteHookDetails:
|
||||
assert pytester.runpytest().ret == 0
|
||||
|
||||
def test_write_pyc(self, pytester: Pytester, tmp_path) -> None:
|
||||
from _pytest.assertion.rewrite import _write_pyc
|
||||
from _pytest.assertion import AssertionState
|
||||
from _pytest.assertion.rewrite import _write_pyc
|
||||
|
||||
config = pytester.parseconfig()
|
||||
state = AssertionState(config, "rewrite")
|
||||
@@ -1087,6 +1087,7 @@ class TestAssertionRewriteHookDetails:
|
||||
an exception that is propagated to the caller.
|
||||
"""
|
||||
import py_compile
|
||||
|
||||
from _pytest.assertion.rewrite import _read_pyc
|
||||
|
||||
source = tmp_path / "source.py"
|
||||
|
||||
@@ -2054,9 +2054,9 @@ class TestPytestPluginsVariable:
|
||||
args = ("--pyargs", "pkg") if use_pyargs else ()
|
||||
res = pytester.runpytest(*args)
|
||||
assert res.ret == (0 if use_pyargs else 2)
|
||||
msg = (
|
||||
msg
|
||||
) = "Defining 'pytest_plugins' in a non-top-level conftest is no longer supported"
|
||||
msg = msg = (
|
||||
"Defining 'pytest_plugins' in a non-top-level conftest is no longer supported"
|
||||
)
|
||||
if use_pyargs:
|
||||
assert msg not in res.stdout.str()
|
||||
else:
|
||||
|
||||
@@ -8,7 +8,6 @@ from _pytest.debugging import _validate_usepdb_cls
|
||||
from _pytest.monkeypatch import MonkeyPatch
|
||||
from _pytest.pytester import Pytester
|
||||
|
||||
|
||||
_ENVIRON_PYTHONBREAKPOINT = os.environ.get("PYTHONBREAKPOINT", "")
|
||||
|
||||
|
||||
|
||||
@@ -4,10 +4,10 @@ Tests and examples for correct "+/-" usage in error diffs.
|
||||
See https://github.com/pytest-dev/pytest/issues/3333 for details.
|
||||
|
||||
"""
|
||||
|
||||
import pytest
|
||||
from _pytest.pytester import Pytester
|
||||
|
||||
|
||||
TESTCASES = [
|
||||
pytest.param(
|
||||
"""
|
||||
|
||||
@@ -113,6 +113,7 @@ def test_cancel_timeout_on_hook(monkeypatch, hook_name) -> None:
|
||||
to timeout before entering pdb (pytest-dev/pytest-faulthandler#12) or any
|
||||
other interactive exception (pytest-dev/pytest-faulthandler#14)."""
|
||||
import faulthandler
|
||||
|
||||
from _pytest import faulthandler as faulthandler_plugin
|
||||
|
||||
called = []
|
||||
|
||||
@@ -942,7 +942,8 @@ def test_parameterset_for_parametrize_marks(
|
||||
)
|
||||
|
||||
config = pytester.parseconfig()
|
||||
from _pytest.mark import pytest_configure, get_empty_parameterset_mark
|
||||
from _pytest.mark import get_empty_parameterset_mark
|
||||
from _pytest.mark import pytest_configure
|
||||
|
||||
pytest_configure(config)
|
||||
result_mark = get_empty_parameterset_mark(config, ["a"], all)
|
||||
@@ -966,7 +967,8 @@ def test_parameterset_for_fail_at_collect(pytester: Pytester) -> None:
|
||||
)
|
||||
|
||||
config = pytester.parseconfig()
|
||||
from _pytest.mark import pytest_configure, get_empty_parameterset_mark
|
||||
from _pytest.mark import get_empty_parameterset_mark
|
||||
from _pytest.mark import pytest_configure
|
||||
|
||||
pytest_configure(config)
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
This ensures all internal packages can be imported without needing the pytest
|
||||
namespace being set, which is critical for the initialization of xdist.
|
||||
"""
|
||||
|
||||
import pkgutil
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
@@ -295,9 +295,9 @@ class TestReportSerialization:
|
||||
|
||||
reprec = pytester.inline_run()
|
||||
if report_class is TestReport:
|
||||
reports: Union[
|
||||
Sequence[TestReport], Sequence[CollectReport]
|
||||
] = reprec.getreports("pytest_runtest_logreport")
|
||||
reports: Union[Sequence[TestReport], Sequence[CollectReport]] = (
|
||||
reprec.getreports("pytest_runtest_logreport")
|
||||
)
|
||||
# we have 3 reports: setup/call/teardown
|
||||
assert len(reports) == 3
|
||||
# get the call report
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
"""Test correct setup/teardowns at module, class, and instance level."""
|
||||
|
||||
from typing import List
|
||||
|
||||
import pytest
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
"""Terminal reporting of the full testing process."""
|
||||
|
||||
import collections
|
||||
import os
|
||||
import sys
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
This file is not executed, it is only checked by mypy to ensure that
|
||||
none of the code triggers any mypy errors.
|
||||
"""
|
||||
|
||||
import contextlib
|
||||
from typing import Optional
|
||||
|
||||
|
||||
Reference in New Issue
Block a user