Skip to content

Commit e7b54dc

Browse files
authored
Merge pull request #226 from nicoddemus/update-pre-commit
2 parents 766cccf + a4cbe1c commit e7b54dc

File tree

6 files changed

+56
-34
lines changed

6 files changed

+56
-34
lines changed

.pre-commit-config.yaml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
exclude: '^($|.*\.bin)'
22
repos:
33
- repo: https://github.com/ambv/black
4-
rev: 19.10b0
4+
rev: 20.8b1
55
hooks:
66
- id: black
77
args: [--safe, --quiet]
88
- repo: https://github.com/pre-commit/pre-commit-hooks
9-
rev: v2.5.0
9+
rev: v3.4.0
1010
hooks:
1111
- id: trailing-whitespace
1212
- id: end-of-file-fixer
@@ -18,8 +18,13 @@ repos:
1818
files: ^(CHANGELOG.rst|README.rst|HOWTORELEASE.rst|changelog/.*)$
1919
language: python
2020
additional_dependencies: [pygments, restructuredtext_lint]
21+
- repo: https://github.com/asottile/reorder_python_imports
22+
rev: v2.3.6
23+
hooks:
24+
- id: reorder-python-imports
25+
args: ['--application-directories=.:src']
2126
- repo: https://github.com/pre-commit/mirrors-mypy
22-
rev: v0.782 # NOTE: keep this in sync with tox.ini
27+
rev: v0.790 # NOTE: keep this in sync with tox.ini
2328
hooks:
2429
- id: mypy
2530
files: ^(src|tests)

setup.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
from io import open
22

3-
from setuptools import setup, find_packages
3+
from setuptools import find_packages
4+
from setuptools import setup
45

56
setup(
67
name="pytest-mock",
78
entry_points={"pytest11": ["pytest_mock = pytest_mock"]},
89
packages=find_packages(where="src"),
910
package_dir={"": "src"},
1011
platforms="any",
11-
package_data={"pytest_mock": ["py.typed"],},
12+
package_data={
13+
"pytest_mock": ["py.typed"],
14+
},
1215
python_requires=">=3.5",
1316
install_requires=["pytest>=5.0"],
1417
use_scm_version={"write_to": "src/pytest_mock/_version.py"},

src/pytest_mock/__init__.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
from pytest_mock.plugin import *
1+
from pytest_mock.plugin import class_mocker
2+
from pytest_mock.plugin import mocker
3+
from pytest_mock.plugin import MockerFixture
4+
from pytest_mock.plugin import module_mocker
5+
from pytest_mock.plugin import package_mocker
6+
from pytest_mock.plugin import pytest_addoption
7+
from pytest_mock.plugin import pytest_configure
8+
from pytest_mock.plugin import PytestMockWarning
9+
from pytest_mock.plugin import session_mocker
210

311
MockFixture = MockerFixture # backward-compatibility only (#204)
412

src/pytest_mock/plugin.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,28 @@
1+
import asyncio
12
import builtins
3+
import functools
4+
import inspect
5+
import sys
26
import unittest.mock
3-
from typing import cast, overload, Generator, Mapping, Iterable, Tuple, TypeVar
7+
import warnings
48
from typing import Any
59
from typing import Callable
10+
from typing import cast
611
from typing import Dict
12+
from typing import Generator
13+
from typing import Iterable
714
from typing import List
8-
15+
from typing import Mapping
916
from typing import Optional
17+
from typing import overload
18+
from typing import Tuple
19+
from typing import TypeVar
1020
from typing import Union
1121

12-
13-
import asyncio
14-
import functools
15-
import inspect
16-
import warnings
17-
import sys
18-
1922
import pytest
2023

21-
from ._util import get_mock_module, parse_ini_boolean
24+
from ._util import get_mock_module
25+
from ._util import parse_ini_boolean
2226

2327
_T = TypeVar("_T")
2428

tests/test_pytest_mock.py

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,17 @@
33
import re
44
import sys
55
from contextlib import contextmanager
6-
from typing import Callable, Any, Tuple, Generator, Type
6+
from typing import Any
7+
from typing import Callable
8+
from typing import Generator
9+
from typing import Tuple
10+
from typing import Type
711
from unittest.mock import MagicMock
812

913
import pytest
10-
from pytest_mock import MockerFixture, PytestMockWarning
14+
15+
from pytest_mock import MockerFixture
16+
from pytest_mock import PytestMockWarning
1117

1218
pytest_plugins = "pytester"
1319

@@ -249,7 +255,8 @@ def bar(self, arg):
249255
),
250256
)
251257
def test_instance_method_spy_exception(
252-
exc_cls: Type[BaseException], mocker: MockerFixture,
258+
exc_cls: Type[BaseException],
259+
mocker: MockerFixture,
253260
) -> None:
254261
class Foo:
255262
def bar(self, arg):
@@ -627,12 +634,12 @@ def test_foo(mocker):
627634

628635

629636
def test_parse_ini_boolean() -> None:
630-
import pytest_mock
637+
from pytest_mock._util import parse_ini_boolean
631638

632-
assert pytest_mock.parse_ini_boolean("True") is True
633-
assert pytest_mock.parse_ini_boolean("false") is False
639+
assert parse_ini_boolean("True") is True
640+
assert parse_ini_boolean("false") is False
634641
with pytest.raises(ValueError):
635-
pytest_mock.parse_ini_boolean("foo")
642+
parse_ini_boolean("foo")
636643

637644

638645
def test_patched_method_parameter_name(mocker: MockerFixture) -> None:
@@ -651,8 +658,7 @@ def request(cls, method, args):
651658

652659

653660
def test_monkeypatch_native(testdir: Any) -> None:
654-
"""Automatically disable monkeypatching when --tb=native.
655-
"""
661+
"""Automatically disable monkeypatching when --tb=native."""
656662
testdir.makepyfile(
657663
"""
658664
def test_foo(mocker):
@@ -676,8 +682,7 @@ def test_foo(mocker):
676682

677683

678684
def test_monkeypatch_no_terminal(testdir: Any) -> None:
679-
"""Don't crash without 'terminal' plugin.
680-
"""
685+
"""Don't crash without 'terminal' plugin."""
681686
testdir.makepyfile(
682687
"""
683688
def test_foo(mocker):
@@ -692,8 +697,7 @@ def test_foo(mocker):
692697

693698

694699
def test_standalone_mock(testdir: Any) -> None:
695-
"""Check that the "mock_use_standalone" is being used.
696-
"""
700+
"""Check that the "mock_use_standalone" is being used."""
697701
testdir.makepyfile(
698702
"""
699703
def test_foo(mocker):
@@ -713,8 +717,7 @@ def test_foo(mocker):
713717

714718
@pytest.mark.usefixtures("needs_assert_rewrite")
715719
def test_detailed_introspection(testdir: Any) -> None:
716-
"""Check that the "mock_use_standalone" is being used.
717-
"""
720+
"""Check that the "mock_use_standalone" is being used."""
718721
testdir.makepyfile(
719722
"""
720723
def test(mocker):
@@ -755,8 +758,7 @@ def test(mocker):
755758
)
756759
@pytest.mark.usefixtures("needs_assert_rewrite")
757760
def test_detailed_introspection_async(testdir: Any) -> None:
758-
"""Check that the "mock_use_standalone" is being used.
759-
"""
761+
"""Check that the "mock_use_standalone" is being used."""
760762
testdir.makepyfile(
761763
"""
762764
import pytest

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ commands = pre-commit run --all-files --show-diff-on-failure
2323
[testenv:mypy]
2424
skip_install = true
2525
deps =
26-
mypy==0.782
26+
mypy==0.790
2727
commands = mypy {posargs:src tests}
2828

2929
[pytest]

0 commit comments

Comments
 (0)