diff --git a/tests/test_coverup_14.py b/tests/test_coverup_14.py deleted file mode 100644 index 8432efd..0000000 --- a/tests/test_coverup_14.py +++ /dev/null @@ -1,54 +0,0 @@ -# file src/coverup/pytest_plugin.py:67-70 -# lines [67, 68, 69, 70] -# branches ['68->exit', '68->69'] - -import json -import pytest -from pathlib import Path -from unittest.mock import MagicMock - -# Assuming the CoverUpPlugin class is part of a module named coverup.pytest_plugin -from coverup.pytest_plugin import CoverUpPlugin - -# Test function to cover the write_outcomes method -def test_write_outcomes(tmp_path, monkeypatch): - # Setup a temporary file for outcomes - outcomes_file = tmp_path / "outcomes.json" - - # Mock the config for CoverUpPlugin - mock_config = MagicMock() - - # Create a CoverUpPlugin instance with a mocked _outcomes_file attribute - plugin = CoverUpPlugin(mock_config) - monkeypatch.setattr(plugin, '_outcomes_file', outcomes_file) - monkeypatch.setattr(plugin, '_outcomes', {1: 'passed', 2: 'failed'}) - - # Call the method under test - plugin.write_outcomes() - - # Verify the file was created and contains the correct content - assert outcomes_file.exists() - with outcomes_file.open() as f: - data = json.load(f) - assert data == {'1': 'passed', '2': 'failed'} - - # Cleanup is handled by pytest's tmp_path fixture, which creates a new temporary directory for each test function - -# Test function to cover the branch when _outcomes_file is None -def test_write_outcomes_no_file(monkeypatch): - # Mock the config for CoverUpPlugin - mock_config = MagicMock() - - # Create a CoverUpPlugin instance with a mocked _outcomes_file attribute set to None - plugin = CoverUpPlugin(mock_config) - monkeypatch.setattr(plugin, '_outcomes_file', None) - - # Mock the open method to ensure it is not called - open_mock = MagicMock() - monkeypatch.setattr(Path, 'open', open_mock) - - # Call the method under test - plugin.write_outcomes() - - # Verify that the open method was not called - open_mock.assert_not_called() diff --git a/tests/test_coverup_7.py b/tests/test_coverup_7.py deleted file mode 100644 index fd0c8c7..0000000 --- a/tests/test_coverup_7.py +++ /dev/null @@ -1,45 +0,0 @@ -# file src/coverup/pytest_plugin.py:21-29 -# lines [21, 22, 23, 24, 26, 28, 29] -# branches ['26->26', '26->28'] - -import pytest -from pathlib import Path -from coverup.pytest_plugin import CoverUpPlugin - -# Mock configuration object -class MockConfig: - def __init__(self, rootpath, stop_after=None, outcomes_file=None): - self.rootpath = rootpath - self._options = { - "--coverup-stop-after": stop_after, - "--coverup-outcomes": outcomes_file, - } - - def getoption(self, name): - return self._options.get(name) - -@pytest.fixture -def mock_config(tmp_path): - return MockConfig(rootpath=tmp_path) - -@pytest.fixture -def mock_config_with_options(tmp_path): - stop_after = tmp_path / "stop_after" - outcomes_file = tmp_path / "outcomes" - return MockConfig(rootpath=tmp_path, stop_after=stop_after, outcomes_file=outcomes_file) - -def test_coverup_plugin_init_without_options(mock_config): - plugin = CoverUpPlugin(mock_config) - assert plugin._rootpath == mock_config.rootpath - assert plugin._stop_after is None - assert plugin._outcomes_file is None - assert not plugin._stop_now - assert plugin._outcomes == {} - -def test_coverup_plugin_init_with_options(mock_config_with_options): - plugin = CoverUpPlugin(mock_config_with_options) - assert plugin._rootpath == mock_config_with_options.rootpath - assert plugin._stop_after == mock_config_with_options.getoption("--coverup-stop-after").resolve() - assert plugin._outcomes_file == mock_config_with_options.getoption("--coverup-outcomes") - assert not plugin._stop_now - assert plugin._outcomes == {}