diff --git a/tests/conftest.py b/tests/conftest.py index 34941eb..ede6c26 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -31,8 +31,7 @@ def _create_toml( ) -> Path: content = content or {} config_toml = toml.dumps(content) - toml_path = create_tmp_file(content=config_toml, filename=filename) - return toml_path + return create_tmp_file(content=config_toml, filename=filename) return _create_toml @@ -48,7 +47,6 @@ def _create_pyproject_toml( ) -> Path: content = content or {"bar": "baz"} config_dict = {"tool": {section_name: content}} - pyproject_path = create_toml(filename=filename, content=config_dict) - return pyproject_path + return create_toml(filename=filename, content=config_dict) return _create_pyproject_toml diff --git a/tests/unit/config_sources/test_toml_source.py b/tests/unit/config_sources/test_toml_source.py index 027e163..22c883b 100644 --- a/tests/unit/config_sources/test_toml_source.py +++ b/tests/unit/config_sources/test_toml_source.py @@ -4,7 +4,7 @@ from textwrap import dedent from typing import Callable -from pytest import raises +import pytest from maison.config_sources.toml_source import TomlSource from maison.errors import BadTomlError @@ -44,5 +44,5 @@ def test_toml_decode_error(self, create_toml: Callable[..., Path]) -> None: toml_source = TomlSource(filepath=toml_path, project_name="acme") error_regex = re.escape(f"Error trying to load toml file '{str(toml_path)}'") - with raises(BadTomlError, match=error_regex): + with pytest.raises(BadTomlError, match=error_regex): toml_source.to_dict() diff --git a/tests/unit/test_utils.py b/tests/unit/test_utils.py index 117caa5..b8fa115 100644 --- a/tests/unit/test_utils.py +++ b/tests/unit/test_utils.py @@ -6,9 +6,7 @@ from unittest.mock import MagicMock from unittest.mock import patch -from pytest import mark -from pytest import param -from pytest import raises +import pytest from maison.utils import deep_merge from maison.utils import get_file_path @@ -125,16 +123,16 @@ def test_absolute_path_not_exist(self) -> None: class TestDeepMerge: """Tests for the `deep_merge` function.""" - @mark.parametrize( - "a,b,expected", + @pytest.mark.parametrize( + ("a", "b", "expected"), [ - param( + pytest.param( {1: 2, 3: 4}, {3: 5, 6: 7}, {1: 2, 3: 5, 6: 7}, id="simple", ), - param( + pytest.param( {1: 2, 3: {4: 5, 6: 7}}, {3: {6: 8, 9: 10}, 11: 12}, {1: 2, 3: {4: 5, 6: 8, 9: 10}, 11: 12}, @@ -165,5 +163,5 @@ def test_incompatible_dicts(self) -> None: dict_a = {1: 2, 2: 5} dict_b = {1: {3: 4}} - with raises(RuntimeError): + with pytest.raises(RuntimeError): deep_merge(dict_a, dict_b)