diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c3003ad43..15c82228a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -23,6 +23,11 @@ repos: language_version: python3 - id: flake8 language_version: python3 +- repo: https://github.com/asottile/reorder_python_imports + rev: v1.3.2 + hooks: + - id: reorder-python-imports + args: ['--application-directories=.:src'] - repo: https://github.com/asottile/pyupgrade rev: v1.8.0 hooks: diff --git a/bench/bench_argcomplete.py b/bench/bench_argcomplete.py index 3ad6dabe5..2b30add08 100644 --- a/bench/bench_argcomplete.py +++ b/bench/bench_argcomplete.py @@ -2,7 +2,6 @@ # 2.7.5 3.3.2 # FilesCompleter 75.1109 69.2116 # FastFilesCompleter 0.7383 1.0760 - import timeit imports = [ diff --git a/bench/skip.py b/bench/skip.py index b105e79f8..25559cc27 100644 --- a/bench/skip.py +++ b/bench/skip.py @@ -1,4 +1,5 @@ from six.moves import range + import pytest diff --git a/doc/en/_themes/flask_theme_support.py b/doc/en/_themes/flask_theme_support.py index 0dcf53b75..b107f2c89 100644 --- a/doc/en/_themes/flask_theme_support.py +++ b/doc/en/_themes/flask_theme_support.py @@ -1,19 +1,17 @@ # flasky extensions. flasky pygments style based on tango style from pygments.style import Style -from pygments.token import ( - Keyword, - Name, - Comment, - String, - Error, - Number, - Operator, - Generic, - Whitespace, - Punctuation, - Other, - Literal, -) +from pygments.token import Comment +from pygments.token import Error +from pygments.token import Generic +from pygments.token import Keyword +from pygments.token import Literal +from pygments.token import Name +from pygments.token import Number +from pygments.token import Operator +from pygments.token import Other +from pygments.token import Punctuation +from pygments.token import String +from pygments.token import Whitespace class FlaskyStyle(Style): diff --git a/doc/en/conf.py b/doc/en/conf.py index 3e881ea01..686a05ba4 100644 --- a/doc/en/conf.py +++ b/doc/en/conf.py @@ -10,17 +10,15 @@ # # All configuration values have a default; values that are commented out # serve to show the default. - # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The full version, including alpha/beta/rc tags. # The short X.Y version. - +import datetime import os import sys -import datetime from _pytest import __version__ as version diff --git a/doc/en/example/assertion/failure_demo.py b/doc/en/example/assertion/failure_demo.py index ae2f5acb2..115fd3e22 100644 --- a/doc/en/example/assertion/failure_demo.py +++ b/doc/en/example/assertion/failure_demo.py @@ -1,7 +1,8 @@ -from pytest import raises -import _pytest._code import six +import _pytest._code +from pytest import raises + def otherfunc(a, b): assert a == b diff --git a/doc/en/example/assertion/global_testmodule_config/conftest.py b/doc/en/example/assertion/global_testmodule_config/conftest.py index 3597ec06d..da89047fe 100644 --- a/doc/en/example/assertion/global_testmodule_config/conftest.py +++ b/doc/en/example/assertion/global_testmodule_config/conftest.py @@ -1,6 +1,7 @@ -import pytest import py +import pytest + mydir = py.path.local(__file__).dirpath() diff --git a/doc/en/example/multipython.py b/doc/en/example/multipython.py index 5e12c9b03..21fdf6fc2 100644 --- a/doc/en/example/multipython.py +++ b/doc/en/example/multipython.py @@ -5,6 +5,7 @@ serialization via the pickle module. import textwrap import py + import pytest pythonlist = ["python2.7", "python3.4", "python3.5"] diff --git a/doc/en/example/nonpython/conftest.py b/doc/en/example/nonpython/conftest.py index 9732dc41b..7c23025af 100644 --- a/doc/en/example/nonpython/conftest.py +++ b/doc/en/example/nonpython/conftest.py @@ -1,5 +1,4 @@ # content of conftest.py - import pytest diff --git a/doc/en/example/py2py3/conftest.py b/doc/en/example/py2py3/conftest.py index 9c1c6fa38..844510a25 100644 --- a/doc/en/example/py2py3/conftest.py +++ b/doc/en/example/py2py3/conftest.py @@ -1,4 +1,5 @@ import sys + import pytest py3 = sys.version_info[0] >= 3 diff --git a/extra/get_issues.py b/extra/get_issues.py index c026972b1..25bfc3e9a 100644 --- a/extra/get_issues.py +++ b/extra/get_issues.py @@ -1,4 +1,5 @@ import json + import py import requests diff --git a/scripts/release.py b/scripts/release.py index f187ba585..5009df359 100644 --- a/scripts/release.py +++ b/scripts/release.py @@ -2,9 +2,13 @@ Invoke development tasks. """ import argparse -from colorama import init, Fore from pathlib import Path -from subprocess import check_output, check_call, call +from subprocess import call +from subprocess import check_call +from subprocess import check_output + +from colorama import Fore +from colorama import init def announce(version): diff --git a/setup.py b/setup.py index ac0739455..ac5f3ffe8 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,5 @@ import os + from setuptools import setup diff --git a/src/_pytest/_argcomplete.py b/src/_pytest/_argcomplete.py index 0d1c2da6a..455c3a7be 100644 --- a/src/_pytest/_argcomplete.py +++ b/src/_pytest/_argcomplete.py @@ -53,9 +53,12 @@ If things do not work right away: which should throw a KeyError: 'COMPLINE' (which is properly set by the global argcomplete script). """ -from __future__ import absolute_import, division, print_function -import sys +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + import os +import sys from glob import glob diff --git a/src/_pytest/_code/__init__.py b/src/_pytest/_code/__init__.py index 7885d51de..fe755a399 100644 --- a/src/_pytest/_code/__init__.py +++ b/src/_pytest/_code/__init__.py @@ -1,11 +1,14 @@ """ python inspection/code generation API """ -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + from .code import Code # noqa from .code import ExceptionInfo # noqa -from .code import Frame # noqa -from .code import Traceback # noqa from .code import filter_traceback # noqa +from .code import Frame # noqa from .code import getrawcode # noqa -from .source import Source # noqa +from .code import Traceback # noqa from .source import compile_ as compile # noqa from .source import getfslineno # noqa +from .source import Source # noqa diff --git a/src/_pytest/_code/_py2traceback.py b/src/_pytest/_code/_py2traceback.py index cceed40ed..8a8b7bc00 100644 --- a/src/_pytest/_code/_py2traceback.py +++ b/src/_pytest/_code/_py2traceback.py @@ -2,8 +2,13 @@ # CHANGES: # - some_str is replaced, trying to create unicode strings # -from __future__ import absolute_import, division, print_function, unicode_literals +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function +from __future__ import unicode_literals + import types + from six import text_type diff --git a/src/_pytest/_code/code.py b/src/_pytest/_code/code.py index c0f6d21a2..d06e24f00 100644 --- a/src/_pytest/_code/code.py +++ b/src/_pytest/_code/code.py @@ -1,19 +1,27 @@ -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + import inspect import pprint +import re import sys import traceback -from inspect import CO_VARARGS, CO_VARKEYWORDS +from inspect import CO_VARARGS +from inspect import CO_VARKEYWORDS +from weakref import ref import attr import pluggy -import re -from weakref import ref -import _pytest -from _pytest.compat import _PY2, _PY3, PY35, safe_str -from six import text_type import py import six +from six import text_type + +import _pytest +from _pytest.compat import _PY2 +from _pytest.compat import _PY3 +from _pytest.compat import PY35 +from _pytest.compat import safe_str builtin_repr = repr diff --git a/src/_pytest/_code/source.py b/src/_pytest/_code/source.py index f78d8bef0..072ddb1b8 100644 --- a/src/_pytest/_code/source.py +++ b/src/_pytest/_code/source.py @@ -1,15 +1,18 @@ -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function import ast -from ast import PyCF_ONLY_AST as _AST_FLAG -from bisect import bisect_right +import inspect import linecache import sys -import six -import inspect import textwrap import tokenize +from ast import PyCF_ONLY_AST as _AST_FLAG +from bisect import bisect_right + import py +import six cpy_compile = compile diff --git a/src/_pytest/assertion/__init__.py b/src/_pytest/assertion/__init__.py index 2c9a8890c..b5c846c2c 100644 --- a/src/_pytest/assertion/__init__.py +++ b/src/_pytest/assertion/__init__.py @@ -1,13 +1,17 @@ """ support for presenting detailed information in failing assertions. """ -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + import sys + import six -from _pytest.assertion import util from _pytest.assertion import rewrite from _pytest.assertion import truncate +from _pytest.assertion import util def pytest_addoption(parser): diff --git a/src/_pytest/assertion/rewrite.py b/src/_pytest/assertion/rewrite.py index 9b3daf9b4..ecb24ff7c 100644 --- a/src/_pytest/assertion/rewrite.py +++ b/src/_pytest/assertion/rewrite.py @@ -1,13 +1,15 @@ """Rewrite assertion AST to produce nice error messages""" -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + import ast import errno -import itertools import imp +import itertools import marshal import os import re -import six import string import struct import sys @@ -15,11 +17,12 @@ import types import atomicwrites import py +import six from _pytest.assertion import util -from _pytest.pathlib import PurePath from _pytest.compat import spec_from_file_location from _pytest.pathlib import fnmatch_ex +from _pytest.pathlib import PurePath # pytest caches rewritten pycs in __pycache__. if hasattr(imp, "get_tag"): diff --git a/src/_pytest/assertion/truncate.py b/src/_pytest/assertion/truncate.py index 79adeca6a..d19c8b61e 100644 --- a/src/_pytest/assertion/truncate.py +++ b/src/_pytest/assertion/truncate.py @@ -4,7 +4,10 @@ Utilities for truncating assertion output. Current default behaviour is to truncate assertion explanations at ~8 terminal lines, unless running in "-vv" mode or running on CI. """ -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + import os import six diff --git a/src/_pytest/assertion/util.py b/src/_pytest/assertion/util.py index 15724ed32..063341095 100644 --- a/src/_pytest/assertion/util.py +++ b/src/_pytest/assertion/util.py @@ -1,10 +1,14 @@ """Utilities for assertion debugging""" -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + import pprint -import _pytest._code import py import six + +import _pytest._code from ..compat import Sequence u = six.text_type diff --git a/src/_pytest/cacheprovider.py b/src/_pytest/cacheprovider.py index 94f42e8cf..8e7f7a804 100755 --- a/src/_pytest/cacheprovider.py +++ b/src/_pytest/cacheprovider.py @@ -4,18 +4,22 @@ merged implementation of the cache provider the name cache was not chosen to ensure pluggy automatically ignores the external pytest-cache """ -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +import json from collections import OrderedDict +import attr import py import six -import attr import pytest -import json - from .compat import _PY2 as PY2 -from .pathlib import Path, resolve_from_str, rmtree +from .pathlib import Path +from .pathlib import resolve_from_str +from .pathlib import rmtree README_CONTENT = u"""\ # pytest cache directory # diff --git a/src/_pytest/capture.py b/src/_pytest/capture.py index dfb488968..bc50ccc3f 100644 --- a/src/_pytest/capture.py +++ b/src/_pytest/capture.py @@ -2,17 +2,20 @@ per-test stdout/stderr capturing mechanism. """ -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function import collections import contextlib -import sys -import os import io +import os +import sys from io import UnsupportedOperation from tempfile import TemporaryFile import six + import pytest from _pytest.compat import CaptureIO diff --git a/src/_pytest/compat.py b/src/_pytest/compat.py index 78bf1bc04..4af0a2339 100644 --- a/src/_pytest/compat.py +++ b/src/_pytest/compat.py @@ -1,7 +1,9 @@ """ python version compatibility code """ -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function import codecs import functools @@ -11,11 +13,12 @@ import sys from contextlib import contextmanager import py +import six +from six import text_type import _pytest -from _pytest.outcomes import TEST_OUTCOME, fail -from six import text_type -import six +from _pytest.outcomes import fail +from _pytest.outcomes import TEST_OUTCOME try: import enum diff --git a/src/_pytest/config/__init__.py b/src/_pytest/config/__init__.py index 47e5c2945..443cf0889 100644 --- a/src/_pytest/config/__init__.py +++ b/src/_pytest/config/__init__.py @@ -1,27 +1,34 @@ """ command line options, ini-file and conftest.py processing. """ -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + import argparse +import copy import inspect +import os import shlex +import sys import types import warnings -import copy -import six -import py -# DON't import pytest here because it causes import cycle troubles -import sys -import os -from _pytest.outcomes import Skipped +import py +import six +from pluggy import HookimplMarker +from pluggy import HookspecMarker +from pluggy import PluginManager import _pytest._code -import _pytest.hookspec # the extension point definitions import _pytest.assertion -from pluggy import PluginManager, HookimplMarker, HookspecMarker -from _pytest._code import ExceptionInfo, filter_traceback +import _pytest.hookspec # the extension point definitions +from .exceptions import PrintHelp +from .exceptions import UsageError +from .findpaths import determine_setup +from .findpaths import exists +from _pytest._code import ExceptionInfo +from _pytest._code import filter_traceback from _pytest.compat import safe_str -from .exceptions import UsageError, PrintHelp -from .findpaths import determine_setup, exists +from _pytest.outcomes import Skipped hookimpl = HookimplMarker("pytest") hookspec = HookspecMarker("pytest") diff --git a/src/_pytest/config/argparsing.py b/src/_pytest/config/argparsing.py index 784b2b212..5012456b9 100644 --- a/src/_pytest/config/argparsing.py +++ b/src/_pytest/config/argparsing.py @@ -1,11 +1,10 @@ -import six -import warnings import argparse - -from gettext import gettext as _ import sys as _sys +import warnings +from gettext import gettext as _ import py +import six from ..main import EXIT_USAGEERROR diff --git a/src/_pytest/config/findpaths.py b/src/_pytest/config/findpaths.py index f99430198..4f371ec7f 100644 --- a/src/_pytest/config/findpaths.py +++ b/src/_pytest/config/findpaths.py @@ -1,5 +1,7 @@ -import py import os + +import py + from .exceptions import UsageError diff --git a/src/_pytest/debugging.py b/src/_pytest/debugging.py index e996c1e28..5a9729d5b 100644 --- a/src/_pytest/debugging.py +++ b/src/_pytest/debugging.py @@ -1,5 +1,7 @@ """ interactive debugging with PDB, the Python Debugger. """ -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function import pdb import sys diff --git a/src/_pytest/deprecated.py b/src/_pytest/deprecated.py index 54886c999..bc1b2a6ec 100644 --- a/src/_pytest/deprecated.py +++ b/src/_pytest/deprecated.py @@ -8,10 +8,12 @@ be removed when the time comes. All constants defined in this module should be either PytestWarning instances or UnformattedWarning in case of warnings which need to format their messages. """ -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function - -from _pytest.warning_types import UnformattedWarning, RemovedInPytest4Warning +from _pytest.warning_types import RemovedInPytest4Warning +from _pytest.warning_types import UnformattedWarning MAIN_STR_ARGS = RemovedInPytest4Warning( diff --git a/src/_pytest/doctest.py b/src/_pytest/doctest.py index 12b871f9f..dbf7df823 100644 --- a/src/_pytest/doctest.py +++ b/src/_pytest/doctest.py @@ -1,12 +1,16 @@ """ discover and run doctests in modules and test files.""" -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function -import traceback -import sys import platform +import sys +import traceback import pytest -from _pytest._code.code import ExceptionInfo, ReprFileLocation, TerminalRepr +from _pytest._code.code import ExceptionInfo +from _pytest._code.code import ReprFileLocation +from _pytest._code.code import TerminalRepr from _pytest.fixtures import FixtureRequest diff --git a/src/_pytest/fixtures.py b/src/_pytest/fixtures.py index cfc187bc2..49c3402dc 100644 --- a/src/_pytest/fixtures.py +++ b/src/_pytest/fixtures.py @@ -1,39 +1,41 @@ -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function import functools import inspect import sys import warnings -from collections import OrderedDict, deque, defaultdict - -import six -from more_itertools import flatten +from collections import defaultdict +from collections import deque +from collections import OrderedDict import attr import py +import six +from more_itertools import flatten from py._code.code import FormattedExcinfo import _pytest from _pytest import nodes from _pytest._code.code import TerminalRepr -from _pytest.compat import ( - NOTSET, - exc_clear, - _format_args, - getfslineno, - get_real_func, - is_generator, - isclass, - getimfunc, - getlocation, - getfuncargnames, - safe_getattr, - FuncargnamesCompatAttr, - get_real_method, - _PytestWrapper, -) +from _pytest.compat import _format_args +from _pytest.compat import _PytestWrapper +from _pytest.compat import exc_clear +from _pytest.compat import FuncargnamesCompatAttr +from _pytest.compat import get_real_func +from _pytest.compat import get_real_method +from _pytest.compat import getfslineno +from _pytest.compat import getfuncargnames +from _pytest.compat import getimfunc +from _pytest.compat import getlocation +from _pytest.compat import is_generator +from _pytest.compat import isclass +from _pytest.compat import NOTSET +from _pytest.compat import safe_getattr from _pytest.deprecated import FIXTURE_FUNCTION_CALL -from _pytest.outcomes import fail, TEST_OUTCOME +from _pytest.outcomes import fail +from _pytest.outcomes import TEST_OUTCOME FIXTURE_MSG = 'fixtures cannot have "pytest_funcarg__" prefix and be decorated with @pytest.fixture:\n{}' diff --git a/src/_pytest/freeze_support.py b/src/_pytest/freeze_support.py index 002e07730..5edf3454c 100644 --- a/src/_pytest/freeze_support.py +++ b/src/_pytest/freeze_support.py @@ -2,7 +2,9 @@ Provides a function to report all internal modules for using freezing tools pytest """ -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function def freeze_includes(): diff --git a/src/_pytest/helpconfig.py b/src/_pytest/helpconfig.py index 88bef95fc..5e60d2a7f 100644 --- a/src/_pytest/helpconfig.py +++ b/src/_pytest/helpconfig.py @@ -1,13 +1,17 @@ """ version info, help messages, tracing configuration. """ -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function -import py -import pytest -from _pytest.config import PrintHelp import os import sys from argparse import Action +import py + +import pytest +from _pytest.config import PrintHelp + class HelpAction(Action): """This is an argparse Action that will raise an exception in diff --git a/src/_pytest/hookspec.py b/src/_pytest/hookspec.py index 533806964..27e55f0ea 100644 --- a/src/_pytest/hookspec.py +++ b/src/_pytest/hookspec.py @@ -1,6 +1,6 @@ """ hook specifications for pytest plugins, invoked from main.py and builtin plugins. """ - from pluggy import HookspecMarker + from .deprecated import PYTEST_NAMESPACE diff --git a/src/_pytest/junitxml.py b/src/_pytest/junitxml.py index a39c94c13..09847c942 100644 --- a/src/_pytest/junitxml.py +++ b/src/_pytest/junitxml.py @@ -8,14 +8,18 @@ Based on initial code from Ross Lawley. Output conforms to https://github.com/jenkinsci/xunit-plugin/blob/master/ src/main/resources/org/jenkinsci/plugins/xunit/types/model/xsd/junit-10.xsd """ -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function import functools -import py import os import re import sys import time + +import py + import pytest from _pytest import nodes from _pytest.config import filename_arg diff --git a/src/_pytest/logging.py b/src/_pytest/logging.py index 0b2f08dea..45fd5950d 100644 --- a/src/_pytest/logging.py +++ b/src/_pytest/logging.py @@ -1,15 +1,18 @@ """ Access and control log capturing. """ -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function import logging -from contextlib import contextmanager import re +from contextlib import contextmanager + +import py import six +import pytest from _pytest.compat import dummy_context_manager from _pytest.config import create_terminal_writer -import pytest -import py DEFAULT_LOG_FORMAT = "%(filename)-25s %(lineno)4d %(levelname)-8s %(message)s" diff --git a/src/_pytest/main.py b/src/_pytest/main.py index 8d4176aea..f27270f26 100644 --- a/src/_pytest/main.py +++ b/src/_pytest/main.py @@ -1,19 +1,22 @@ """ core implementation of testing process: init, session, runtest loop. """ -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function import contextlib import functools import os import pkgutil -import six import sys -import _pytest -from _pytest import nodes -import _pytest._code import py +import six -from _pytest.config import directory_arg, UsageError, hookimpl +import _pytest._code +from _pytest import nodes +from _pytest.config import directory_arg +from _pytest.config import hookimpl +from _pytest.config import UsageError from _pytest.outcomes import exit from _pytest.runner import collect_one_node diff --git a/src/_pytest/mark/__init__.py b/src/_pytest/mark/__init__.py index 390057428..b6495dd03 100644 --- a/src/_pytest/mark/__init__.py +++ b/src/_pytest/mark/__init__.py @@ -1,18 +1,20 @@ """ generic mechanism for marking and selecting python functions. """ -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +from .legacy import matchkeyword +from .legacy import matchmark +from .structures import EMPTY_PARAMETERSET_OPTION +from .structures import get_empty_parameterset_mark +from .structures import Mark +from .structures import MARK_GEN +from .structures import MarkDecorator +from .structures import MarkGenerator +from .structures import MarkInfo +from .structures import ParameterSet +from .structures import transfer_markers from _pytest.config import UsageError -from .structures import ( - ParameterSet, - EMPTY_PARAMETERSET_OPTION, - MARK_GEN, - Mark, - MarkInfo, - MarkDecorator, - MarkGenerator, - transfer_markers, - get_empty_parameterset_mark, -) -from .legacy import matchkeyword, matchmark __all__ = [ "Mark", diff --git a/src/_pytest/mark/evaluate.py b/src/_pytest/mark/evaluate.py index 6736cb799..793bff79e 100644 --- a/src/_pytest/mark/evaluate.py +++ b/src/_pytest/mark/evaluate.py @@ -1,10 +1,12 @@ import os -import six -import sys import platform +import sys import traceback -from ..outcomes import fail, TEST_OUTCOME +import six + +from ..outcomes import fail +from ..outcomes import TEST_OUTCOME def cached_eval(config, expr, d): diff --git a/src/_pytest/mark/legacy.py b/src/_pytest/mark/legacy.py index 0d0d852ce..cea136bff 100644 --- a/src/_pytest/mark/legacy.py +++ b/src/_pytest/mark/legacy.py @@ -2,9 +2,10 @@ this is a place where we put datastructures used by legacy apis we hope ot remove """ -import attr import keyword +import attr + from _pytest.config import UsageError diff --git a/src/_pytest/mark/structures.py b/src/_pytest/mark/structures.py index 32822c2bb..2ca1d830a 100644 --- a/src/_pytest/mark/structures.py +++ b/src/_pytest/mark/structures.py @@ -5,12 +5,15 @@ from functools import reduce from operator import attrgetter import attr - -from _pytest.outcomes import fail -from ..deprecated import MARK_PARAMETERSET_UNPACKING, MARK_INFO_ATTRIBUTE -from ..compat import NOTSET, getfslineno, MappingMixin from six.moves import map +from ..compat import getfslineno +from ..compat import MappingMixin +from ..compat import NOTSET +from ..deprecated import MARK_INFO_ATTRIBUTE +from ..deprecated import MARK_PARAMETERSET_UNPACKING +from _pytest.outcomes import fail + EMPTY_PARAMETERSET_OPTION = "empty_parameter_set_mark" diff --git a/src/_pytest/monkeypatch.py b/src/_pytest/monkeypatch.py index 4bd6b607d..2efdb73ae 100644 --- a/src/_pytest/monkeypatch.py +++ b/src/_pytest/monkeypatch.py @@ -1,9 +1,11 @@ """ monkeypatching and mocking functionality. """ -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function import os -import sys import re +import sys import warnings from contextlib import contextmanager diff --git a/src/_pytest/nodes.py b/src/_pytest/nodes.py index d80895ab5..76d8d6a8a 100644 --- a/src/_pytest/nodes.py +++ b/src/_pytest/nodes.py @@ -1,18 +1,20 @@ -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + import os import warnings -import six -import py import attr +import py +import six -import _pytest import _pytest._code from _pytest.compat import getfslineno +from _pytest.mark.structures import MarkInfo +from _pytest.mark.structures import NodeKeywords from _pytest.outcomes import fail -from _pytest.mark.structures import NodeKeywords, MarkInfo - SEP = "/" tracebackcutdir = py.path.local(_pytest.__file__).dirpath() diff --git a/src/_pytest/nose.py b/src/_pytest/nose.py index bb2e4277d..4bfa9c583 100644 --- a/src/_pytest/nose.py +++ b/src/_pytest/nose.py @@ -1,9 +1,13 @@ """ run test suites written for nose. """ -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function import sys -from _pytest import unittest, runner, python +from _pytest import python +from _pytest import runner +from _pytest import unittest from _pytest.config import hookimpl diff --git a/src/_pytest/outcomes.py b/src/_pytest/outcomes.py index 4c7958384..cd08c0d48 100644 --- a/src/_pytest/outcomes.py +++ b/src/_pytest/outcomes.py @@ -2,7 +2,10 @@ exception classes and constants handling test outcomes as well as functions creating them """ -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + import sys diff --git a/src/_pytest/pastebin.py b/src/_pytest/pastebin.py index 6af202d1f..9559e3265 100644 --- a/src/_pytest/pastebin.py +++ b/src/_pytest/pastebin.py @@ -1,11 +1,15 @@ """ submit failure or test session information to a pastebin service. """ -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function -import pytest -import six import sys import tempfile +import six + +import pytest + def pytest_addoption(parser): group = parser.getgroup("terminal reporting") diff --git a/src/_pytest/pathlib.py b/src/_pytest/pathlib.py index bf46cbf70..b3519c682 100644 --- a/src/_pytest/pathlib.py +++ b/src/_pytest/pathlib.py @@ -1,19 +1,22 @@ - -import os -import errno import atexit -import operator -import six -import sys -from functools import reduce -import uuid -from six.moves import map -import itertools -import shutil -from os.path import expanduser, expandvars, isabs, sep -from posixpath import sep as posix_sep +import errno import fnmatch +import itertools +import operator +import os +import shutil import stat +import sys +import uuid +from functools import reduce +from os.path import expanduser +from os.path import expandvars +from os.path import isabs +from os.path import sep +from posixpath import sep as posix_sep + +import six +from six.moves import map from .compat import PY36 diff --git a/src/_pytest/pytester.py b/src/_pytest/pytester.py index 8782a30ba..ca24ff1b0 100644 --- a/src/_pytest/pytester.py +++ b/src/_pytest/pytester.py @@ -1,5 +1,7 @@ """(disabled by default) support for testing pytest and pytest plugins.""" -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function import codecs import gc @@ -7,23 +9,25 @@ import os import platform import re import subprocess -import six import sys import time import traceback from fnmatch import fnmatch - from weakref import WeakKeyDictionary -from _pytest.capture import MultiCapture, SysCapture -from _pytest._code import Source -from _pytest.main import Session, EXIT_INTERRUPTED, EXIT_OK -from _pytest.assertion.rewrite import AssertionRewritingHook -from _pytest.pathlib import Path -from _pytest.compat import safe_str - import py +import six + import pytest +from _pytest._code import Source +from _pytest.assertion.rewrite import AssertionRewritingHook +from _pytest.capture import MultiCapture +from _pytest.capture import SysCapture +from _pytest.compat import safe_str +from _pytest.main import EXIT_INTERRUPTED +from _pytest.main import EXIT_OK +from _pytest.main import Session +from _pytest.pathlib import Path IGNORE_PAM = [ # filenames added when obtaining details about the current user u"/var/lib/sss/mc/passwd" diff --git a/src/_pytest/python.py b/src/_pytest/python.py index ef3e3a730..6fd74acb1 100644 --- a/src/_pytest/python.py +++ b/src/_pytest/python.py @@ -1,50 +1,48 @@ """ Python test discovery, setup and run of test functions. """ -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function +import collections import fnmatch import inspect -import sys import os -import collections +import sys import warnings from textwrap import dedent - import py import six -from _pytest.main import FSHookProxy -from _pytest.config import hookimpl import _pytest -from _pytest._code import filter_traceback +from _pytest import deprecated from _pytest import fixtures from _pytest import nodes -from _pytest import deprecated -from _pytest.compat import ( - isclass, - isfunction, - is_generator, - ascii_escaped, - REGEX_TYPE, - STRING_TYPES, - NoneType, - NOTSET, - get_real_func, - getfslineno, - safe_getattr, - safe_str, - getlocation, - enum, - get_default_arg_names, - getimfunc, -) +from _pytest._code import filter_traceback +from _pytest.compat import ascii_escaped +from _pytest.compat import enum +from _pytest.compat import get_default_arg_names +from _pytest.compat import get_real_func +from _pytest.compat import getfslineno +from _pytest.compat import getimfunc +from _pytest.compat import getlocation +from _pytest.compat import is_generator +from _pytest.compat import isclass +from _pytest.compat import isfunction +from _pytest.compat import NoneType +from _pytest.compat import NOTSET +from _pytest.compat import REGEX_TYPE +from _pytest.compat import safe_getattr +from _pytest.compat import safe_str +from _pytest.compat import STRING_TYPES +from _pytest.config import hookimpl +from _pytest.main import FSHookProxy +from _pytest.mark.structures import get_unpacked_marks +from _pytest.mark.structures import normalize_mark_list +from _pytest.mark.structures import transfer_markers from _pytest.outcomes import fail -from _pytest.mark.structures import ( - transfer_markers, - get_unpacked_marks, - normalize_mark_list, -) -from _pytest.warning_types import RemovedInPytest4Warning, PytestWarning +from _pytest.warning_types import PytestWarning +from _pytest.warning_types import RemovedInPytest4Warning def pyobj_property(name): diff --git a/src/_pytest/python_api.py b/src/_pytest/python_api.py index 6cd17de25..805cd85ad 100644 --- a/src/_pytest/python_api.py +++ b/src/_pytest/python_api.py @@ -1,20 +1,20 @@ import math import pprint import sys -from numbers import Number from decimal import Decimal +from numbers import Number import six -from six.moves import zip, filterfalse from more_itertools.more import always_iterable +from six.moves import filterfalse +from six.moves import zip -from _pytest.compat import isclass - -from _pytest.compat import Mapping, Sequence -from _pytest.compat import STRING_TYPES - -from _pytest.outcomes import fail import _pytest._code +from _pytest.compat import isclass +from _pytest.compat import Mapping +from _pytest.compat import Sequence +from _pytest.compat import STRING_TYPES +from _pytest.outcomes import fail BASE_TYPE = (type, STRING_TYPES) diff --git a/src/_pytest/recwarn.py b/src/_pytest/recwarn.py index 8738fe0b8..4049110c5 100644 --- a/src/_pytest/recwarn.py +++ b/src/_pytest/recwarn.py @@ -1,15 +1,16 @@ """ recording warnings during test function execution. """ -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function import inspect - -import _pytest._code import re import sys import warnings import six +import _pytest._code from _pytest.fixtures import yield_fixture from _pytest.outcomes import fail diff --git a/src/_pytest/reports.py b/src/_pytest/reports.py index a57c9fa80..b2010cc2e 100644 --- a/src/_pytest/reports.py +++ b/src/_pytest/reports.py @@ -1,4 +1,5 @@ import py + from _pytest._code.code import TerminalRepr diff --git a/src/_pytest/resultlog.py b/src/_pytest/resultlog.py index 9ae90e770..3efdbea6e 100644 --- a/src/_pytest/resultlog.py +++ b/src/_pytest/resultlog.py @@ -1,10 +1,13 @@ """ log machine-parseable test session result information in a plain text file. """ -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +import os import py -import os def pytest_addoption(parser): diff --git a/src/_pytest/runner.py b/src/_pytest/runner.py index 057317993..4d4b06d7c 100644 --- a/src/_pytest/runner.py +++ b/src/_pytest/runner.py @@ -1,5 +1,7 @@ """ basic collect and runtest protocol implementations """ -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function import bdb import os @@ -7,10 +9,14 @@ import sys from time import time import six -from _pytest._code.code import ExceptionInfo -from _pytest.outcomes import skip, Skipped, TEST_OUTCOME -from .reports import TestReport, CollectReport, CollectErrorRepr +from .reports import CollectErrorRepr +from .reports import CollectReport +from .reports import TestReport +from _pytest._code.code import ExceptionInfo +from _pytest.outcomes import skip +from _pytest.outcomes import Skipped +from _pytest.outcomes import TEST_OUTCOME # # pytest plugin hooks diff --git a/src/_pytest/setuponly.py b/src/_pytest/setuponly.py index c3edc5f81..4bd4ad6d8 100644 --- a/src/_pytest/setuponly.py +++ b/src/_pytest/setuponly.py @@ -1,7 +1,10 @@ -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +import sys import pytest -import sys def pytest_addoption(parser): diff --git a/src/_pytest/setupplan.py b/src/_pytest/setupplan.py index 23f4f97e6..351e0be65 100644 --- a/src/_pytest/setupplan.py +++ b/src/_pytest/setupplan.py @@ -1,4 +1,6 @@ -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function import pytest diff --git a/src/_pytest/skipping.py b/src/_pytest/skipping.py index 90afd6de8..f755fc4eb 100644 --- a/src/_pytest/skipping.py +++ b/src/_pytest/skipping.py @@ -1,9 +1,13 @@ """ support for skip/xfail functions and markers. """ -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function from _pytest.config import hookimpl from _pytest.mark.evaluate import MarkEvaluator -from _pytest.outcomes import fail, skip, xfail +from _pytest.outcomes import fail +from _pytest.outcomes import skip +from _pytest.outcomes import xfail def pytest_addoption(parser): diff --git a/src/_pytest/terminal.py b/src/_pytest/terminal.py index 37186a121..0d5a08185 100644 --- a/src/_pytest/terminal.py +++ b/src/_pytest/terminal.py @@ -2,8 +2,11 @@ This is a good source for looking at the various reporting hooks. """ -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function +import argparse import itertools import platform import sys @@ -17,16 +20,11 @@ from more_itertools import collapse import pytest from _pytest import nodes -from _pytest.main import ( - EXIT_OK, - EXIT_TESTSFAILED, - EXIT_INTERRUPTED, - EXIT_USAGEERROR, - EXIT_NOTESTSCOLLECTED, -) - - -import argparse +from _pytest.main import EXIT_INTERRUPTED +from _pytest.main import EXIT_NOTESTSCOLLECTED +from _pytest.main import EXIT_OK +from _pytest.main import EXIT_TESTSFAILED +from _pytest.main import EXIT_USAGEERROR class MoreQuietAction(argparse.Action): diff --git a/src/_pytest/tmpdir.py b/src/_pytest/tmpdir.py index 1963f14c0..6287c1705 100644 --- a/src/_pytest/tmpdir.py +++ b/src/_pytest/tmpdir.py @@ -1,22 +1,23 @@ """ support for providing temporary directories to test functions. """ -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function import os import re -import pytest -import py -from _pytest.monkeypatch import MonkeyPatch -import attr import tempfile import warnings -from .pathlib import ( - Path, - make_numbered_dir, - make_numbered_dir_with_cleanup, - ensure_reset_dir, - LOCK_TIMEOUT, -) +import attr +import py + +import pytest +from .pathlib import ensure_reset_dir +from .pathlib import LOCK_TIMEOUT +from .pathlib import make_numbered_dir +from .pathlib import make_numbered_dir_with_cleanup +from .pathlib import Path +from _pytest.monkeypatch import MonkeyPatch @attr.s diff --git a/src/_pytest/unittest.py b/src/_pytest/unittest.py index a2fd6ad5a..a38a60d8e 100644 --- a/src/_pytest/unittest.py +++ b/src/_pytest/unittest.py @@ -1,15 +1,21 @@ """ discovery and running of std-library "unittest" style tests. """ -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function import sys import traceback -# for transferring markers import _pytest._code -from _pytest.config import hookimpl -from _pytest.outcomes import fail, skip, xfail -from _pytest.python import transfer_markers, Class, Module, Function from _pytest.compat import getimfunc +from _pytest.config import hookimpl +from _pytest.outcomes import fail +from _pytest.outcomes import skip +from _pytest.outcomes import xfail +from _pytest.python import Class +from _pytest.python import Function +from _pytest.python import Module +from _pytest.python import transfer_markers def pytest_pycollect_makeitem(collector, name, obj): diff --git a/src/_pytest/warnings.py b/src/_pytest/warnings.py index e900ff067..52afbe784 100644 --- a/src/_pytest/warnings.py +++ b/src/_pytest/warnings.py @@ -1,11 +1,12 @@ -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function import sys import warnings from contextlib import contextmanager import pytest - from _pytest import compat diff --git a/src/pytest.py b/src/pytest.py index e173fd3d4..14ed1acaa 100644 --- a/src/pytest.py +++ b/src/pytest.py @@ -2,30 +2,44 @@ """ pytest: unit and functional testing with Python. """ - - # else we are imported - -from _pytest.config import main, UsageError, cmdline, hookspec, hookimpl -from _pytest.fixtures import fixture, yield_fixture -from _pytest.assertion import register_assert_rewrite -from _pytest.freeze_support import freeze_includes from _pytest import __version__ +from _pytest.assertion import register_assert_rewrite +from _pytest.config import cmdline +from _pytest.config import hookimpl +from _pytest.config import hookspec +from _pytest.config import main +from _pytest.config import UsageError from _pytest.debugging import pytestPDB as __pytestPDB -from _pytest.recwarn import warns, deprecated_call -from _pytest.outcomes import fail, skip, importorskip, exit, xfail -from _pytest.mark import MARK_GEN as mark, param -from _pytest.main import Session -from _pytest.nodes import Item, Collector, File from _pytest.fixtures import fillfixtures as _fillfuncargs -from _pytest.python import Package, Module, Class, Instance, Function, Generator -from _pytest.python_api import approx, raises -from _pytest.warning_types import ( - PytestWarning, - PytestDeprecationWarning, - RemovedInPytest4Warning, - PytestExperimentalApiWarning, -) +from _pytest.fixtures import fixture +from _pytest.fixtures import yield_fixture +from _pytest.freeze_support import freeze_includes +from _pytest.main import Session +from _pytest.mark import MARK_GEN as mark +from _pytest.mark import param +from _pytest.nodes import Collector +from _pytest.nodes import File +from _pytest.nodes import Item +from _pytest.outcomes import exit +from _pytest.outcomes import fail +from _pytest.outcomes import importorskip +from _pytest.outcomes import skip +from _pytest.outcomes import xfail +from _pytest.python import Class +from _pytest.python import Function +from _pytest.python import Generator +from _pytest.python import Instance +from _pytest.python import Module +from _pytest.python import Package +from _pytest.python_api import approx +from _pytest.python_api import raises +from _pytest.recwarn import deprecated_call +from _pytest.recwarn import warns +from _pytest.warning_types import PytestDeprecationWarning +from _pytest.warning_types import PytestExperimentalApiWarning +from _pytest.warning_types import PytestWarning +from _pytest.warning_types import RemovedInPytest4Warning set_trace = __pytestPDB.set_trace diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index 0a7eb2e03..8917de6b2 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -1,15 +1,19 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + import os import sys import textwrap import types +import py import six -import py import pytest -from _pytest.main import EXIT_NOTESTSCOLLECTED, EXIT_USAGEERROR +from _pytest.main import EXIT_NOTESTSCOLLECTED +from _pytest.main import EXIT_USAGEERROR def prepend_pythonpath(*dirs): diff --git a/testing/code/test_code.py b/testing/code/test_code.py index a144bc80e..20ca0bfce 100644 --- a/testing/code/test_code.py +++ b/testing/code/test_code.py @@ -1,13 +1,15 @@ # coding: utf-8 -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function import sys +from six import text_type +from test_excinfo import TWMock + import _pytest._code import pytest -from six import text_type - -from test_excinfo import TWMock try: import mock diff --git a/testing/code/test_excinfo.py b/testing/code/test_excinfo.py index 92460cd29..c8f4c904d 100644 --- a/testing/code/test_excinfo.py +++ b/testing/code/test_excinfo.py @@ -1,24 +1,25 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function import operator import os import sys import textwrap -import _pytest -import py -import pytest -import six -from _pytest._code.code import ( - ExceptionInfo, - FormattedExcinfo, - ReprExceptionInfo, - ExceptionChainRepr, -) -from six.moves import queue +import py +import six +from six.moves import queue from test_source import astonly +import _pytest +import pytest +from _pytest._code.code import ExceptionChainRepr +from _pytest._code.code import ExceptionInfo +from _pytest._code.code import FormattedExcinfo +from _pytest._code.code import ReprExceptionInfo + try: import importlib except ImportError: diff --git a/testing/code/test_source.py b/testing/code/test_source.py index f31748c0e..3ee46c1b8 100644 --- a/testing/code/test_source.py +++ b/testing/code/test_source.py @@ -2,13 +2,17 @@ # flake8: noqa # disable flake check on this file because some constructs are strange # or redundant on purpose and can't be disable on a line-by-line basis -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + import inspect import sys +import six + import _pytest._code import pytest -import six from _pytest._code import Source from _pytest._code.source import ast diff --git a/testing/deprecated_test.py b/testing/deprecated_test.py index 649ebcd38..e4e2860d1 100644 --- a/testing/deprecated_test.py +++ b/testing/deprecated_test.py @@ -1,4 +1,6 @@ -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function import os diff --git a/testing/example_scripts/issue_519.py b/testing/example_scripts/issue_519.py index 5dc8b163c..7199df820 100644 --- a/testing/example_scripts/issue_519.py +++ b/testing/example_scripts/issue_519.py @@ -1,6 +1,7 @@ -import pytest import pprint +import pytest + def pytest_generate_tests(metafunc): if "arg1" in metafunc.fixturenames: diff --git a/testing/example_scripts/unittest/test_parametrized_fixture_error_message.py b/testing/example_scripts/unittest/test_parametrized_fixture_error_message.py index 0b85bef3a..d421ce927 100644 --- a/testing/example_scripts/unittest/test_parametrized_fixture_error_message.py +++ b/testing/example_scripts/unittest/test_parametrized_fixture_error_message.py @@ -1,6 +1,7 @@ -import pytest import unittest +import pytest + @pytest.fixture(params=[1, 2]) def two(request): diff --git a/testing/logging/test_formatter.py b/testing/logging/test_formatter.py index 84ef4dd2f..abceaf857 100644 --- a/testing/logging/test_formatter.py +++ b/testing/logging/test_formatter.py @@ -1,6 +1,7 @@ import logging import py.io + from _pytest.logging import ColoredLevelFormatter diff --git a/testing/logging/test_reporting.py b/testing/logging/test_reporting.py index 5863e0115..9debc2165 100644 --- a/testing/logging/test_reporting.py +++ b/testing/logging/test_reporting.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -import re import os +import re from io import open import six diff --git a/testing/python/approx.py b/testing/python/approx.py index f9eefb372..96433d52b 100644 --- a/testing/python/approx.py +++ b/testing/python/approx.py @@ -1,13 +1,14 @@ # encoding: utf-8 +import doctest import operator import sys -import pytest -import doctest - -from pytest import approx -from operator import eq, ne from decimal import Decimal from fractions import Fraction +from operator import eq +from operator import ne + +import pytest +from pytest import approx inf, nan = float("inf"), float("nan") diff --git a/testing/python/fixture.py b/testing/python/fixture.py index 02304ac32..86cd51114 100644 --- a/testing/python/fixture.py +++ b/testing/python/fixture.py @@ -3,10 +3,11 @@ import sys import textwrap import pytest -from _pytest.pytester import get_public_names -from _pytest.fixtures import FixtureLookupError, FixtureRequest from _pytest import fixtures +from _pytest.fixtures import FixtureLookupError +from _pytest.fixtures import FixtureRequest from _pytest.pathlib import Path +from _pytest.pytester import get_public_names def test_getfuncargnames(): diff --git a/testing/python/metafunc.py b/testing/python/metafunc.py index fea59ee98..77fefdcac 100644 --- a/testing/python/metafunc.py +++ b/testing/python/metafunc.py @@ -1,14 +1,16 @@ # -*- coding: utf-8 -*- import re import sys -import attr import textwrap -import pytest -from _pytest import python, fixtures +import attr import hypothesis from hypothesis import strategies +import pytest +from _pytest import fixtures +from _pytest import python + PY3 = sys.version_info >= (3, 0) diff --git a/testing/python/raises.py b/testing/python/raises.py index 732e1e82c..9b9eadf1a 100644 --- a/testing/python/raises.py +++ b/testing/python/raises.py @@ -1,7 +1,8 @@ -from _pytest.outcomes import Failed -import pytest import sys +import pytest +from _pytest.outcomes import Failed + class TestRaises(object): def test_raises(self): diff --git a/testing/test_argcomplete.py b/testing/test_argcomplete.py index fc2306b00..060cc2b49 100644 --- a/testing/test_argcomplete.py +++ b/testing/test_argcomplete.py @@ -1,6 +1,10 @@ -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + import subprocess import sys + import pytest # test for _argcomplete but not specific for any application diff --git a/testing/test_assertion.py b/testing/test_assertion.py index 6a2a1ed38..94fe9d272 100644 --- a/testing/test_assertion.py +++ b/testing/test_assertion.py @@ -1,14 +1,18 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + import sys import textwrap -import _pytest.assertion as plugin import py -import pytest import six -from _pytest.assertion import util + +import _pytest.assertion as plugin +import pytest from _pytest.assertion import truncate +from _pytest.assertion import util PY3 = sys.version_info >= (3, 0) diff --git a/testing/test_assertrewrite.py b/testing/test_assertrewrite.py index 5153fc741..acbabb68b 100644 --- a/testing/test_assertrewrite.py +++ b/testing/test_assertrewrite.py @@ -1,5 +1,7 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function import glob import os @@ -8,17 +10,16 @@ import stat import sys import textwrap import zipfile + import py -import pytest import six import _pytest._code +import pytest from _pytest.assertion import util -from _pytest.assertion.rewrite import ( - rewrite_asserts, - PYTEST_TAG, - AssertionRewritingHook, -) +from _pytest.assertion.rewrite import AssertionRewritingHook +from _pytest.assertion.rewrite import PYTEST_TAG +from _pytest.assertion.rewrite import rewrite_asserts from _pytest.main import EXIT_NOTESTSCOLLECTED ast = pytest.importorskip("ast") diff --git a/testing/test_cacheprovider.py b/testing/test_cacheprovider.py index 2444d8bc1..43b8392e5 100644 --- a/testing/test_cacheprovider.py +++ b/testing/test_cacheprovider.py @@ -1,12 +1,15 @@ -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function +import os +import shutil import sys import textwrap import py + import pytest -import os -import shutil pytest_plugins = ("pytester",) diff --git a/testing/test_capture.py b/testing/test_capture.py index 3dc422efe..4b9b543a5 100644 --- a/testing/test_capture.py +++ b/testing/test_capture.py @@ -1,22 +1,26 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function -# note: py.io capture tests where copied from -# pylib 1.4.20.dev2 (rev 13d9af95547e) -import pickle +import contextlib import os +import pickle import sys import textwrap from io import UnsupportedOperation import py -import pytest -import contextlib from six import text_type + +import pytest from _pytest import capture from _pytest.capture import CaptureManager from _pytest.main import EXIT_NOTESTSCOLLECTED +# note: py.io capture tests where copied from +# pylib 1.4.20.dev2 (rev 13d9af95547e) + needsosdup = pytest.mark.skipif( not hasattr(os, "dup"), reason="test needs os.dup, not available on this platform" diff --git a/testing/test_collection.py b/testing/test_collection.py index 9cd085778..7f6791dae 100644 --- a/testing/test_collection.py +++ b/testing/test_collection.py @@ -1,10 +1,15 @@ -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + import pprint import sys import textwrap -import pytest -from _pytest.main import Session, EXIT_NOTESTSCOLLECTED, _in_venv +import pytest +from _pytest.main import _in_venv +from _pytest.main import EXIT_NOTESTSCOLLECTED +from _pytest.main import Session class TestCollector(object): diff --git a/testing/test_compat.py b/testing/test_compat.py index a6249d14b..494acd738 100644 --- a/testing/test_compat.py +++ b/testing/test_compat.py @@ -1,11 +1,17 @@ -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + import sys from functools import wraps import six import pytest -from _pytest.compat import is_generator, get_real_func, safe_getattr, _PytestWrapper +from _pytest.compat import _PytestWrapper +from _pytest.compat import get_real_func +from _pytest.compat import is_generator +from _pytest.compat import safe_getattr from _pytest.outcomes import OutcomeException diff --git a/testing/test_config.py b/testing/test_config.py index 8d67d7e9d..82466df1f 100644 --- a/testing/test_config.py +++ b/testing/test_config.py @@ -1,11 +1,16 @@ -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + import sys import textwrap -import pytest import _pytest._code -from _pytest.config.findpaths import getcfg, get_common_ancestor, determine_setup +import pytest from _pytest.config import _iter_rewritable_modules +from _pytest.config.findpaths import determine_setup +from _pytest.config.findpaths import get_common_ancestor +from _pytest.config.findpaths import getcfg from _pytest.main import EXIT_NOTESTSCOLLECTED diff --git a/testing/test_conftest.py b/testing/test_conftest.py index 44126613e..7d14d790d 100644 --- a/testing/test_conftest.py +++ b/testing/test_conftest.py @@ -1,10 +1,16 @@ -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + import textwrap import py + import pytest from _pytest.config import PytestPluginManager -from _pytest.main import EXIT_NOTESTSCOLLECTED, EXIT_OK, EXIT_USAGEERROR +from _pytest.main import EXIT_NOTESTSCOLLECTED +from _pytest.main import EXIT_OK +from _pytest.main import EXIT_USAGEERROR @pytest.fixture(scope="module", params=["global", "inpackage"]) diff --git a/testing/test_doctest.py b/testing/test_doctest.py index d7815b1cf..cccfdabe6 100644 --- a/testing/test_doctest.py +++ b/testing/test_doctest.py @@ -1,10 +1,16 @@ # encoding: utf-8 -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + import sys import textwrap -from _pytest.compat import MODULE_NOT_FOUND_ERROR -from _pytest.doctest import DoctestItem, DoctestModule, DoctestTextfile + import pytest +from _pytest.compat import MODULE_NOT_FOUND_ERROR +from _pytest.doctest import DoctestItem +from _pytest.doctest import DoctestModule +from _pytest.doctest import DoctestTextfile class TestDoctests(object): diff --git a/testing/test_entry_points.py b/testing/test_entry_points.py index 8f734778f..dcb9dd525 100644 --- a/testing/test_entry_points.py +++ b/testing/test_entry_points.py @@ -1,4 +1,7 @@ -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + import pkg_resources import pytest diff --git a/testing/test_helpconfig.py b/testing/test_helpconfig.py index ceea56ccc..9c7806d54 100644 --- a/testing/test_helpconfig.py +++ b/testing/test_helpconfig.py @@ -1,6 +1,9 @@ -from __future__ import absolute_import, division, print_function -from _pytest.main import EXIT_NOTESTSCOLLECTED +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + import pytest +from _pytest.main import EXIT_NOTESTSCOLLECTED def test_version(testdir, pytestconfig): diff --git a/testing/test_junitxml.py b/testing/test_junitxml.py index 079b01f32..db308b688 100644 --- a/testing/test_junitxml.py +++ b/testing/test_junitxml.py @@ -1,12 +1,16 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function -from xml.dom import minidom -import py -import sys -import os -from _pytest.junitxml import LogXML -import pytest +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function +import os +import sys +from xml.dom import minidom + +import py + +import pytest +from _pytest.junitxml import LogXML from _pytest.reports import BaseReport diff --git a/testing/test_mark.py b/testing/test_mark.py index 48a680297..7109da9b6 100644 --- a/testing/test_mark.py +++ b/testing/test_mark.py @@ -1,4 +1,7 @@ -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + import os import sys diff --git a/testing/test_modimport.py b/testing/test_modimport.py index f7b92a0b6..64e9d7261 100644 --- a/testing/test_modimport.py +++ b/testing/test_modimport.py @@ -1,8 +1,10 @@ -import py import subprocess import sys -import pytest + +import py + import _pytest +import pytest MODSET = [ x diff --git a/testing/test_monkeypatch.py b/testing/test_monkeypatch.py index 853c0192f..d250d24e7 100644 --- a/testing/test_monkeypatch.py +++ b/testing/test_monkeypatch.py @@ -1,4 +1,7 @@ -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + import os import sys import textwrap diff --git a/testing/test_nodes.py b/testing/test_nodes.py index 9219f45e5..d55184ef2 100644 --- a/testing/test_nodes.py +++ b/testing/test_nodes.py @@ -1,5 +1,4 @@ import pytest - from _pytest import nodes diff --git a/testing/test_nose.py b/testing/test_nose.py index d63b30584..b2c724b8d 100644 --- a/testing/test_nose.py +++ b/testing/test_nose.py @@ -1,4 +1,7 @@ -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + import pytest diff --git a/testing/test_parseopt.py b/testing/test_parseopt.py index fab288e7f..0dafa248b 100644 --- a/testing/test_parseopt.py +++ b/testing/test_parseopt.py @@ -1,8 +1,13 @@ -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + import argparse -import sys import os +import sys + import py + import pytest from _pytest.config import argparsing as parseopt diff --git a/testing/test_pastebin.py b/testing/test_pastebin.py index 1005dcba4..04f316e52 100644 --- a/testing/test_pastebin.py +++ b/testing/test_pastebin.py @@ -1,6 +1,10 @@ # encoding: utf-8 -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + import sys + import pytest diff --git a/testing/test_paths.py b/testing/test_paths.py index 2eb07bbd4..65ee9b634 100644 --- a/testing/test_paths.py +++ b/testing/test_paths.py @@ -3,7 +3,6 @@ import sys import py import pytest - from _pytest.pathlib import fnmatch_ex diff --git a/testing/test_pdb.py b/testing/test_pdb.py index 0cda739a4..56fe5fc7a 100644 --- a/testing/test_pdb.py +++ b/testing/test_pdb.py @@ -1,7 +1,10 @@ -from __future__ import absolute_import, division, print_function -import sys -import platform +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + import os +import platform +import sys import _pytest._code import pytest diff --git a/testing/test_pluginmanager.py b/testing/test_pluginmanager.py index 39f5fb91f..0bee415f2 100644 --- a/testing/test_pluginmanager.py +++ b/testing/test_pluginmanager.py @@ -1,13 +1,18 @@ # encoding: UTF-8 -from __future__ import absolute_import, division, print_function -import pytest +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + import os import re import sys import types -from _pytest.config import get_config, PytestPluginManager -from _pytest.main import EXIT_NOTESTSCOLLECTED, Session +import pytest +from _pytest.config import get_config +from _pytest.config import PytestPluginManager +from _pytest.main import EXIT_NOTESTSCOLLECTED +from _pytest.main import Session @pytest.fixture diff --git a/testing/test_pytester.py b/testing/test_pytester.py index cf6a51367..0c28bc91b 100644 --- a/testing/test_pytester.py +++ b/testing/test_pytester.py @@ -1,15 +1,24 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + import os -import py.path -import pytest import sys import time + +import py.path + import _pytest.pytester as pytester -from _pytest.pytester import HookRecorder -from _pytest.pytester import CwdSnapshot, SysModulesSnapshot, SysPathsSnapshot +import pytest from _pytest.config import PytestPluginManager -from _pytest.main import EXIT_OK, EXIT_TESTSFAILED, EXIT_NOTESTSCOLLECTED +from _pytest.main import EXIT_NOTESTSCOLLECTED +from _pytest.main import EXIT_OK +from _pytest.main import EXIT_TESTSFAILED +from _pytest.pytester import CwdSnapshot +from _pytest.pytester import HookRecorder +from _pytest.pytester import SysModulesSnapshot +from _pytest.pytester import SysPathsSnapshot def test_make_hook_recorder(testdir): diff --git a/testing/test_recwarn.py b/testing/test_recwarn.py index e1d44f174..726f43763 100644 --- a/testing/test_recwarn.py +++ b/testing/test_recwarn.py @@ -1,6 +1,9 @@ -from __future__ import absolute_import, division, print_function -import warnings +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + import re +import warnings import pytest from _pytest.recwarn import WarningsRecorder diff --git a/testing/test_resultlog.py b/testing/test_resultlog.py index 1bb0cca48..36f584e57 100644 --- a/testing/test_resultlog.py +++ b/testing/test_resultlog.py @@ -1,16 +1,20 @@ -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + import os -import _pytest._code import py + +import _pytest._code import pytest -from _pytest.nodes import Node, Item, FSCollector -from _pytest.resultlog import ( - generic_path, - ResultLog, - pytest_configure, - pytest_unconfigure, -) +from _pytest.nodes import FSCollector +from _pytest.nodes import Item +from _pytest.nodes import Node +from _pytest.resultlog import generic_path +from _pytest.resultlog import pytest_configure +from _pytest.resultlog import pytest_unconfigure +from _pytest.resultlog import ResultLog pytestmark = pytest.mark.filterwarnings("ignore:--result-log is deprecated") diff --git a/testing/test_runner.py b/testing/test_runner.py index a3fffe81a..2d55e9e5a 100644 --- a/testing/test_runner.py +++ b/testing/test_runner.py @@ -1,14 +1,21 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function -import _pytest._code import inspect import os -import py -import pytest import sys import types -from _pytest import runner, main, outcomes, reports + +import py + +import _pytest._code +import pytest +from _pytest import main +from _pytest import outcomes +from _pytest import reports +from _pytest import runner class TestSetupState(object): diff --git a/testing/test_runner_xunit.py b/testing/test_runner_xunit.py index 8316aafbf..4538b18db 100644 --- a/testing/test_runner_xunit.py +++ b/testing/test_runner_xunit.py @@ -2,7 +2,10 @@ test correct setup/teardowns at module, class, and instance level """ -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + import pytest diff --git a/testing/test_session.py b/testing/test_session.py index 50ce91534..6225a2c0d 100644 --- a/testing/test_session.py +++ b/testing/test_session.py @@ -1,7 +1,8 @@ -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function import pytest - from _pytest.main import EXIT_NOTESTSCOLLECTED diff --git a/testing/test_skipping.py b/testing/test_skipping.py index 507ce126a..231c3b6aa 100644 --- a/testing/test_skipping.py +++ b/testing/test_skipping.py @@ -1,9 +1,14 @@ -from __future__ import absolute_import, division, print_function -import pytest +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + import sys -from _pytest.skipping import MarkEvaluator, folded_skips, pytest_runtest_setup +import pytest from _pytest.runner import runtestprotocol +from _pytest.skipping import folded_skips +from _pytest.skipping import MarkEvaluator +from _pytest.skipping import pytest_runtest_setup class TestEvaluator(object): diff --git a/testing/test_terminal.py b/testing/test_terminal.py index af2dc2f00..2f7d02bba 100644 --- a/testing/test_terminal.py +++ b/testing/test_terminal.py @@ -1,7 +1,10 @@ """ terminal reporting of the full testing process. """ -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + import collections import os import sys @@ -9,10 +12,14 @@ import textwrap import pluggy import py + import pytest from _pytest.main import EXIT_NOTESTSCOLLECTED -from _pytest.terminal import TerminalReporter, repr_pythonversion, getreportopt -from _pytest.terminal import build_summary_stats_line, _plugin_nameversions +from _pytest.terminal import _plugin_nameversions +from _pytest.terminal import build_summary_stats_line +from _pytest.terminal import getreportopt +from _pytest.terminal import repr_pythonversion +from _pytest.terminal import TerminalReporter DistInfo = collections.namedtuple("DistInfo", ["project_name", "version"]) diff --git a/testing/test_tmpdir.py b/testing/test_tmpdir.py index 3c413e7c2..d0bb3881a 100644 --- a/testing/test_tmpdir.py +++ b/testing/test_tmpdir.py @@ -1,4 +1,7 @@ -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + import sys import six diff --git a/testing/test_unittest.py b/testing/test_unittest.py index c47fce8c9..28ce90a3d 100644 --- a/testing/test_unittest.py +++ b/testing/test_unittest.py @@ -1,8 +1,12 @@ -from __future__ import absolute_import, division, print_function -from _pytest.main import EXIT_NOTESTSCOLLECTED -import pytest +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + import gc +import pytest +from _pytest.main import EXIT_NOTESTSCOLLECTED + def test_simple_unittest(testdir): testpath = testdir.makepyfile(