Skip to content
This repository was archived by the owner on Feb 17, 2021. It is now read-only.

Commit 45fa99a

Browse files
author
staticdev
committed
Return to Mock from Any
1 parent eacbe7e commit 45fa99a

2 files changed

Lines changed: 16 additions & 16 deletions

File tree

tests/test_main.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,49 @@
11
"""Test cases for the __main__ module."""
2-
from typing import Any
32
from unittest.mock import Mock
43

4+
import click.testing
55
import pytest
6-
from click.testing import CliRunner
76
from pytest_mock import MockFixture
87

98
from toml_validator import __main__
109

1110

1211
@pytest.fixture
13-
def runner() -> CliRunner:
12+
def runner() -> click.testing.CliRunner:
1413
"""Fixture for invoking command-line interfaces."""
15-
return CliRunner()
14+
return click.testing.CliRunner()
1615

1716

1817
@pytest.fixture
19-
def mock_validation_validate_extension(mocker: MockFixture) -> Any:
18+
def mock_validation_validate_extension(mocker: MockFixture) -> Mock:
2019
"""Fixture for mocking validation.validate_extension."""
2120
return mocker.patch("toml_validator.validation.validate_extension")
2221

2322

2423
@pytest.fixture
25-
def mock_validation_validate_toml_no_error(mocker: MockFixture) -> Any:
24+
def mock_validation_validate_toml_no_error(mocker: MockFixture) -> Mock:
2625
"""Fixture for mocking validation.validate_toml with no errors."""
2726
mock = mocker.patch("toml_validator.validation.validate_toml")
2827
mock.return_value = ""
2928
return mock
3029

3130

3231
@pytest.fixture
33-
def mock_validation_validate_toml_with_error(mocker: MockFixture) -> Any:
32+
def mock_validation_validate_toml_with_error(mocker: MockFixture) -> Mock:
3433
"""Fixture for mocking validation.validate_toml with error."""
3534
mock = mocker.patch("toml_validator.validation.validate_toml")
3635
mock.return_value = "|some error description|"
3736
return mock
3837

3938

40-
def test_main_without_argument(runner: CliRunner) -> None:
39+
def test_main_without_argument(runner: click.testing.CliRunner) -> None:
4140
"""It exits with a status code of 2."""
4241
result = runner.invoke(__main__.main)
4342
assert result.exit_code == 2
4443

4544

4645
def test_main_with_argument_success(
47-
runner: CliRunner,
46+
runner: click.testing.CliRunner,
4847
mock_validation_validate_extension: Mock,
4948
mock_validation_validate_toml_no_error: Mock,
5049
) -> None:
@@ -61,7 +60,7 @@ def test_main_with_argument_success(
6160

6261

6362
def test_main_with_argument_fail(
64-
runner: CliRunner,
63+
runner: click.testing.CliRunner,
6564
mock_validation_validate_extension: Mock,
6665
mock_validation_validate_toml_with_error: Mock,
6766
) -> None:
@@ -78,7 +77,9 @@ def test_main_with_argument_fail(
7877

7978

8079
@pytest.mark.e2e
81-
def test_main_without_arguments_in_production_env(runner: CliRunner) -> None:
80+
def test_main_without_arguments_in_production_env(
81+
runner: click.testing.CliRunner,
82+
) -> None:
8283
"""It exits with a status code of 2 (e2e)."""
8384
result = runner.invoke(__main__.main)
8485
assert result.exit_code == 2

tests/test_validation.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
"""Test cases for the validation module."""
2-
from typing import Any
32
from unittest.mock import Mock
43

54
import pytest
@@ -10,27 +9,27 @@
109

1110

1211
@pytest.fixture
13-
def mock_tomlkit_parse(mocker: MockFixture) -> Any:
12+
def mock_tomlkit_parse(mocker: MockFixture) -> Mock:
1413
"""Fixture for mocking tomlkit.parse."""
1514
return mocker.patch("tomlkit.parse")
1615

1716

1817
@pytest.fixture
19-
def mock_tomlkit_parse_exception(mocker: MockFixture) -> Any:
18+
def mock_tomlkit_parse_exception(mocker: MockFixture) -> Mock:
2019
"""Fixture for mocking tomlkit.parse."""
2120
mock = mocker.patch("tomlkit.parse")
2221
mock.side_effect = TOMLKitError("|some tomlkit error|")
2322
return mock
2423

2524

2625
@pytest.fixture
27-
def mock_open_valid_file(mocker: MockFixture) -> Any:
26+
def mock_open_valid_file(mocker: MockFixture) -> Mock:
2827
"""Fixture for mocking build-in open for valid TOML file."""
2928
return mocker.patch("builtins.open", mocker.mock_open(read_data="[x]\na = 3"))
3029

3130

3231
@pytest.fixture
33-
def mock_open_invalid_file(mocker: MockFixture) -> Any:
32+
def mock_open_invalid_file(mocker: MockFixture) -> Mock:
3433
"""Fixture for mocking build-in open for valid TOML file."""
3534
return mocker.patch(
3635
"builtins.open", mocker.mock_open(read_data="[x]\na = 3\n[x]\na = 3")

0 commit comments

Comments
 (0)