from pathlib import Path
import unittest


ROOT = Path(__file__).resolve().parents[1]


class TestDependencyPolicyTests(unittest.TestCase):
    def test_pytest_is_declared_once_at_an_exact_test_only_version(self) -> None:
        self.assertEqual(
            "pytest==8.3.5\n",
            (ROOT / "requirements-test.txt").read_text(encoding="utf-8"),
        )
        self.assertNotIn(
            "pytest",
            (ROOT / "requirements.txt").read_text(encoding="utf-8"),
        )
        self.assertIn(
            "import pytest",
            (ROOT / "tests" / "test_capital_loss_guard.py").read_text(encoding="utf-8"),
        )
