11"""Test cases for the __main__ module."""
2+ from typing import Any
23from unittest .mock import Mock
34
5+ import click .testing
46import pytest
5- from click .testing import CliRunner
67from pytest_mock import MockFixture
78
89from toml_validator import __main__
910
1011
1112@pytest .fixture
12- def runner () -> CliRunner :
13+ def runner () -> click . testing . CliRunner :
1314 """Fixture for invoking command-line interfaces."""
14- return CliRunner ()
15+ return click . testing . CliRunner ()
1516
1617
1718@pytest .fixture
18- def mock_validation_validate_extension (mocker : MockFixture ) -> Mock :
19+ def mock_validation_validate_extension (mocker : MockFixture ) -> Any :
1920 """Fixture for mocking validation.validate_extension."""
2021 return mocker .patch ("toml_validator.validation.validate_extension" )
2122
2223
2324@pytest .fixture
24- def mock_validation_validate_toml_no_error (mocker : MockFixture ) -> Mock :
25+ def mock_validation_validate_toml_no_error (mocker : MockFixture ) -> Any :
2526 """Fixture for mocking validation.validate_toml with no errors."""
2627 mock = mocker .patch ("toml_validator.validation.validate_toml" )
2728 mock .return_value = ""
2829 return mock
2930
3031
3132@pytest .fixture
32- def mock_validation_validate_toml_with_error (mocker : MockFixture ) -> Mock :
33+ def mock_validation_validate_toml_with_error (mocker : MockFixture ) -> Any :
3334 """Fixture for mocking validation.validate_toml with error."""
3435 mock = mocker .patch ("toml_validator.validation.validate_toml" )
3536 mock .return_value = "|some error description|"
3637 return mock
3738
3839
39- def test_main_without_argument (runner : CliRunner ):
40+ def test_main_without_argument (runner : click . testing . CliRunner ) -> None :
4041 """It exits with a status code of 2."""
4142 result = runner .invoke (__main__ .main )
4243 assert result .exit_code == 2
4344
4445
4546def test_main_with_argument_success (
46- runner : CliRunner ,
47+ runner : click . testing . CliRunner ,
4748 mock_validation_validate_extension : Mock ,
4849 mock_validation_validate_toml_no_error : Mock ,
49- ):
50+ ) -> None :
5051 """It exits with a status code of zero."""
5152 with runner .isolated_filesystem ():
5253 with open ("file.toml" , "w" ) as f :
@@ -60,10 +61,10 @@ def test_main_with_argument_success(
6061
6162
6263def test_main_with_argument_fail (
63- runner : CliRunner ,
64+ runner : click . testing . CliRunner ,
6465 mock_validation_validate_extension : Mock ,
6566 mock_validation_validate_toml_with_error : Mock ,
66- ):
67+ ) -> None :
6768 """It outputs error."""
6869 with runner .isolated_filesystem ():
6970 with open ("file.toml" , "w" ) as f :
@@ -77,7 +78,9 @@ def test_main_with_argument_fail(
7778
7879
7980@pytest .mark .e2e
80- def test_main_without_arguments_in_production_env (runner : CliRunner ):
81+ def test_main_without_arguments_in_production_env (
82+ runner : click .testing .CliRunner ,
83+ ) -> None :
8184 """It exits with a status code of 2 (e2e)."""
8285 result = runner .invoke (__main__ .main )
8386 assert result .exit_code == 2
0 commit comments