Skip to content

Commit

Permalink
refactor(tests): remove redundant docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
pivoshenko committed Feb 8, 2025
1 parent 6dc4177 commit 30701cf
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 57 deletions.
4 changes: 0 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ def create_dotenv_file(tmp_path: Path) -> Callable[[dict[str, str], str], None]:
"""Get a dotenv file."""

def create(content: dict[str, str], filename: str) -> None:
"""Create a dotenv file."""

dotenv_file = tmp_path / ".." / ".." / ".." / filename
stream = (f"{kay!s}={value!s}" for kay, value in content.items())
dotenv_file.write_text("/n".join(stream))
Expand All @@ -34,8 +32,6 @@ def remove_dotenv_file() -> Callable[[str], None]:
"""Remove a dotenv file."""

def remove(filepath: str) -> None:
"""Remove a dotenv file."""

if os.path.exists(filepath):
os.unlink(filepath)

Expand Down
28 changes: 1 addition & 27 deletions tests/dotenv/test_core.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Tests for the module ``src/poetry_plugin_dotenv/dotenv/core.py``."""
"""Tests for the module that contains core dotenv functionality."""

from __future__ import annotations

Expand Down Expand Up @@ -44,8 +44,6 @@ def prepare_file_hierarchy(path: Path) -> tuple[Path, Path]:


def test_find_dotenv_no_file_no_raise(tmp_path: Path) -> None:
"""Test ``find`` function."""

*_, leaf = prepare_file_hierarchy(tmp_path)
os.chdir(str(leaf))

Expand All @@ -55,8 +53,6 @@ def test_find_dotenv_no_file_no_raise(tmp_path: Path) -> None:


def test_find_dotenv_found(tmp_path: Path) -> None:
"""Test ``find`` function."""

(root, leaf) = prepare_file_hierarchy(tmp_path)
os.chdir(str(leaf))
dotenv_file = root / ".env"
Expand All @@ -69,8 +65,6 @@ def test_find_dotenv_found(tmp_path: Path) -> None:

@mock.patch.dict(os.environ, {}, clear=True)
def test_load_dotenv_existing_file(dotenv_file: str) -> None:
"""Test ``load`` function."""

with open(dotenv_file, "w") as env_file:
env_file.write("a=b")

Expand All @@ -82,8 +76,6 @@ def test_load_dotenv_existing_file(dotenv_file: str) -> None:

@mock.patch.dict(os.environ, {"a": "c"}, clear=True)
def test_load_dotenv_existing_variable_no_override(dotenv_file: str) -> None:
"""Test ``load`` function."""

with open(dotenv_file, "w") as env_file:
env_file.write("a=b")

Expand All @@ -95,8 +87,6 @@ def test_load_dotenv_existing_variable_no_override(dotenv_file: str) -> None:

@mock.patch.dict(os.environ, {"a": "c"}, clear=True)
def test_load_dotenv_existing_variable_override(dotenv_file: str) -> None:
"""Test ``load`` function."""

with open(dotenv_file, "w") as env_file:
env_file.write("a=b")

Expand All @@ -108,8 +98,6 @@ def test_load_dotenv_existing_variable_override(dotenv_file: str) -> None:

@mock.patch.dict(os.environ, {"a": "c"}, clear=True)
def test_load_dotenv_redefine_var_used_in_file_no_override(dotenv_file: str) -> None:
"""Test ``load`` function."""

with open(dotenv_file, "w") as env_file:
env_file.write('a=b\nd="${a}"')

Expand All @@ -121,8 +109,6 @@ def test_load_dotenv_redefine_var_used_in_file_no_override(dotenv_file: str) ->

@mock.patch.dict(os.environ, {"a": "c"}, clear=True)
def test_load_dotenv_redefine_var_used_in_file_with_override(dotenv_file: str) -> None:
"""Test ``load`` function."""

with open(dotenv_file, "w") as env_file:
env_file.write('a=b\nd="${a}"')

Expand All @@ -134,8 +120,6 @@ def test_load_dotenv_redefine_var_used_in_file_with_override(dotenv_file: str) -

@mock.patch.dict(os.environ, {}, clear=True)
def test_load_dotenv_string_io() -> None:
"""Test ``load`` function."""

stream = io.StringIO("a=à")

result = dotenv.load(stream=stream)
Expand All @@ -146,8 +130,6 @@ def test_load_dotenv_string_io() -> None:

@mock.patch.dict(os.environ, {}, clear=True)
def test_load_dotenv_file_stream(dotenv_file: str) -> None:
"""Test ``load`` function."""

with open(dotenv_file, "w") as env_file:
env_file.write("a=b")

Expand All @@ -159,8 +141,6 @@ def test_load_dotenv_file_stream(dotenv_file: str) -> None:


def test_load_dotenv_in_current_dir(tmp_path: Path) -> None:
"""Test ``load`` function."""

dotenv_path = tmp_path / ".env"
dotenv_path.write_bytes(b"a=b")
code_path = tmp_path / "code.py"
Expand All @@ -184,8 +164,6 @@ def test_load_dotenv_in_current_dir(tmp_path: Path) -> None:


def test_dotenv_values_file(dotenv_file: str) -> None:
"""Test ``values`` function."""

with open(dotenv_file, "w") as env_file:
env_file.write("a=b")

Expand All @@ -195,8 +173,6 @@ def test_dotenv_values_file(dotenv_file: str) -> None:


def test_dotenv_values_file_stream(dotenv_file: str) -> None:
"""Test ``dotenv_values`` function."""

with open(dotenv_file, "w") as env_file:
env_file.write("a=b")

Expand Down Expand Up @@ -238,8 +214,6 @@ def test_dotenv_values_string_io(
*,
interpolate: bool,
) -> None:
"""Test ``values`` function."""

with mock.patch.dict(os.environ, env, clear=True):
stream = io.StringIO(string)
stream.seek(0)
Expand Down
4 changes: 1 addition & 3 deletions tests/dotenv/test_parsers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Tests for the module ``src/poetry_plugin_dotenv/dotenv/parsers.py``."""
"""Tests for the module that contains dotenv parsers."""

from __future__ import annotations

Expand Down Expand Up @@ -541,7 +541,5 @@
],
)
def test_parse_stream(test_input: str, expected: list[Binding]) -> None:
"""Test ``parse_stream`` function."""

parsed_stream = list(parse_stream(io.StringIO(test_input)))
assert parsed_stream == expected
6 changes: 1 addition & 5 deletions tests/dotenv/test_variables.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Tests for the module ``src/poetry_plugin_dotenv/dotenv/variables.py``."""
"""Tests for the module that contains models of the dotenv variables and literals."""

from __future__ import annotations

Expand Down Expand Up @@ -36,8 +36,6 @@
],
)
def test_parse(value: str, expected: list[variables.Literal | variables.Variable]) -> None:
"""Test ``parse`` function."""

parsed_vars = list(variables.parse(value))
assert parsed_vars == expected

Expand All @@ -51,7 +49,5 @@ def test_parse(value: str, expected: list[variables.Literal | variables.Variable
],
)
def test_resolve(model: variables.Literal | variables.Variable, expected: str) -> None:
"""Test ``resolve`` method."""

env = OrderedDict({"a": "b", "c": "d"})
assert model.resolve(env) == expected
4 changes: 1 addition & 3 deletions tests/test_config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Tests for the module ``src/poetry_plugin_dotenv/config.py``."""
"""Tests for the module that contains plugin's configurator."""

from __future__ import annotations

Expand Down Expand Up @@ -26,6 +26,4 @@
],
)
def test__as_bool(value: str, expected_bool: bool) -> None: # noqa: FBT001
"""Test for the ``_as_bool`` function."""

assert expected_bool == _as_bool(value)
6 changes: 1 addition & 5 deletions tests/test_plugin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Tests for the module ``src/poetry_plugin_dotenv/plugin.py``."""
"""Tests for the that contains the core functionality of the plugin."""

from __future__ import annotations

Expand All @@ -22,8 +22,6 @@ def test_default_dotenv_file(
create_dotenv_file: Callable[[dict[str, str], str], None],
remove_dotenv_file: Callable[[str], None],
) -> None:
"""Test for the ``load`` method."""

event = mocker.MagicMock()
event.command = EnvCommand()
event.io.input.option.return_value = None
Expand All @@ -45,8 +43,6 @@ def test_dotenv_file_doesnt_exist(
mocker: pytest_mock.MockFixture,
remove_dotenv_file: Callable[[str], None],
) -> None:
"""Test for the ``load`` method."""

event = mocker.MagicMock()
event.command = EnvCommand()
event.io.input.option.return_value = None
Expand Down
6 changes: 1 addition & 5 deletions tests/test_plugin_os_config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Tests for the module ``src/poetry_plugin_dotenv/plugin.py`` with OS as config source."""
"""Tests for the that contains the core functionality of the plugin."""

from __future__ import annotations

Expand Down Expand Up @@ -26,8 +26,6 @@ def test_dev_dotenv_file_os_config(
create_dotenv_file: Callable[[dict[str, str], str], None],
remove_dotenv_file: Callable[[str], None],
) -> None:
"""Test for the ``load`` method."""

event = mocker.MagicMock()
event.command = EnvCommand()
event.io.input.option.return_value = None
Expand All @@ -51,8 +49,6 @@ def test_without_dotenv_file_os_config(
create_dotenv_file: Callable[[dict[str, str], str], None],
remove_dotenv_file: Callable[[str], None],
) -> None:
"""Test for the ``load`` method."""

event = mocker.MagicMock()
event.command = EnvCommand()
event.io.input.option.return_value = None
Expand Down
6 changes: 1 addition & 5 deletions tests/test_plugin_toml_config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Tests for the module ``src/poetry_plugin_dotenv/plugin.py`` with TOML as config source."""
"""Tests for the that contains the core functionality of the plugin."""

from __future__ import annotations

Expand Down Expand Up @@ -39,8 +39,6 @@ def test_dev_dotenv_file_toml_config(
create_dotenv_file: Callable[[dict[str, str], str], None],
remove_dotenv_file: Callable[[str], None],
) -> None:
"""Test for the ``load`` method."""

event = mocker.MagicMock()
event.command = EnvCommand()
event.io.input.option.return_value = None
Expand Down Expand Up @@ -78,8 +76,6 @@ def test_without_dotenv_file_toml_config(
create_dotenv_file: Callable[[dict[str, str], str], None],
remove_dotenv_file: Callable[[str], None],
) -> None:
"""Test for the ``load`` method."""

event = mocker.MagicMock()
event.command = EnvCommand()
event.io.input.option.return_value = None
Expand Down

0 comments on commit 30701cf

Please sign in to comment.