Skip to content

Commit

Permalink
Remove unnecessary pytest-mock dependency (#559)
Browse files Browse the repository at this point in the history
  • Loading branch information
jairhenrique authored Oct 15, 2024
1 parent 03d466d commit bccc391
Show file tree
Hide file tree
Showing 3 changed files with 681 additions and 556 deletions.
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ dev-dependencies = [
"hypothesis",
"nox",
"pytest",
"pytest-mock",
"ruff",
"sphinx",
"sphinx-rtd-theme",
Expand Down
15 changes: 8 additions & 7 deletions tests/unittests/test_config.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
"""Tests for config loading functions."""

import io
from unittest import mock

import pytest

from cosmic_ray.config import ConfigDict, ConfigError, load_config, serialize_config


def test_load_valid_stdin(mocker):
def test_load_valid_stdin():
temp_stdin = io.StringIO()
temp_stdin.name = "stringio"
config = ConfigDict()
config["key"] = "value"
temp_stdin.write(serialize_config(config))
temp_stdin.seek(0)
mocker.patch("sys.stdin", temp_stdin)
assert load_config()["key"] == "value"
with mock.patch("cosmic_ray.config.sys.stdin", temp_stdin):
assert load_config()["key"] == "value"


def test_load_invalid_stdin_raises_ConfigError(mocker):
def test_load_invalid_stdin_raises_ConfigError():
temp_stdin = io.StringIO()
temp_stdin.name = "stringio"
temp_stdin.write("{invalid")
temp_stdin.seek(0)
mocker.patch("sys.stdin", temp_stdin)

with pytest.raises(ConfigError):
load_config()
with mock.patch("cosmic_ray.config.sys.stdin", temp_stdin):
with pytest.raises(ConfigError):
load_config()


def test_load_from_valid_config_file(tmpdir):
Expand Down
Loading

0 comments on commit bccc391

Please sign in to comment.