Skip to content

Commit

Permalink
Turn TestCase into a Pytest style test function
Browse files Browse the repository at this point in the history
  • Loading branch information
akaihola committed Mar 8, 2024
1 parent 3f6f5c0 commit 02c49bf
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions src/darker/tests/test_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,20 @@
import io
from contextlib import redirect_stderr
from pathlib import Path
from unittest import TestCase
from unittest.mock import MagicMock, patch

from darker import files


class BlackTestCase(TestCase):
@patch("darker.files.find_user_pyproject_toml")
def test_find_pyproject_toml(self, find_user_pyproject_toml: MagicMock) -> None:
find_user_pyproject_toml.side_effect = RuntimeError()
@patch("darker.files.find_user_pyproject_toml")
def test_find_pyproject_toml(find_user_pyproject_toml: MagicMock) -> None:
"""Test `files.find_pyproject_toml` with no user home directory."""
find_user_pyproject_toml.side_effect = RuntimeError()
with redirect_stderr(io.StringIO()) as stderr:
# end of test setup

with redirect_stderr(io.StringIO()) as stderr:
result = files.find_pyproject_toml(
path_search_start=(str(Path.cwd().root),)
)
result = files.find_pyproject_toml(path_search_start=(str(Path.cwd().root),))

assert result is None
err = stderr.getvalue()
assert "Ignoring user configuration" in err
assert result is None
err = stderr.getvalue()
assert "Ignoring user configuration" in err

0 comments on commit 02c49bf

Please sign in to comment.