@@ -88,7 +88,7 @@ def test_no_pyproject_toml(
8888 )
8989
9090 @pytest .mark .usefixtures ("_vary_network_conn" )
91- def test_pytest_used (
91+ def test_pytest_integration (
9292 self , uv_init_dir : Path , capfd : pytest .CaptureFixture [str ]
9393 ):
9494 with change_cwd (uv_init_dir ):
@@ -106,7 +106,7 @@ def test_pytest_used(
106106 out , err = capfd .readouterr ()
107107 assert not err
108108 assert out == (
109- "✔ Adding dependency 'coverage' to the 'test' group in 'pyproject.toml'.\n "
109+ "✔ Adding dependencies 'coverage', 'pytest-cov' to the 'test' group in \n 'pyproject.toml'.\n "
110110 "✔ Adding coverage config to 'pyproject.toml'.\n "
111111 "☐ Run 'pytest --cov' to run your tests with coverage.\n "
112112 )
@@ -141,6 +141,27 @@ def test_roundtrip(self, uv_init_dir: Path, capfd: pytest.CaptureFixture[str]):
141141 "✔ Removing dependency 'coverage' from the 'test' group in 'pyproject.toml'.\n "
142142 )
143143
144+ def test_pytest_integration (
145+ self , uv_init_dir : Path , capfd : pytest .CaptureFixture [str ]
146+ ):
147+ with change_cwd (uv_init_dir ):
148+ # Arrange
149+ with usethis_config .set (quiet = True ):
150+ use_pytest ()
151+ use_coverage ()
152+
153+ # Act
154+ use_coverage (remove = True )
155+
156+ # Assert
157+ assert get_deps_from_group ("test" ) == [Dependency (name = "pytest" )]
158+ out , err = capfd .readouterr ()
159+ assert not err
160+ assert out == (
161+ "✔ Removing coverage config from 'pyproject.toml'.\n "
162+ "✔ Removing dependencies 'coverage', 'pytest-cov' from the 'test' group in \n 'pyproject.toml'.\n "
163+ )
164+
144165
145166class TestDeptry :
146167 class TestAdd :
@@ -810,13 +831,14 @@ def test_no_pyproject(self, tmp_path: Path, capfd: pytest.CaptureFixture[str]):
810831 assert is_dep_satisfied_in (
811832 Dependency (name = "pytest" ), in_ = list (deps_from_test )
812833 )
813- assert is_dep_satisfied_in (
834+ # pytest-cov should only be added when we are using coverage
835+ assert not is_dep_satisfied_in (
814836 Dependency (name = "pytest-cov" ), in_ = list (deps_from_test )
815837 )
816838 out , _ = capfd .readouterr ()
817839 assert out == (
818840 "✔ Writing 'pyproject.toml'.\n "
819- "✔ Adding dependencies 'pytest', 'pytest-cov' to the 'test' group in \n 'pyproject.toml'.\n "
841+ "✔ Adding dependency 'pytest' to the 'test' group in 'pyproject.toml'.\n "
820842 "✔ Adding pytest config to 'pyproject.toml'.\n "
821843 "✔ Creating '/tests'.\n "
822844 "✔ Writing '/tests/conftest.py'.\n "
@@ -838,7 +860,7 @@ def test_bitbucket_integration(self, uv_init_dir: Path):
838860 assert "pytest" in (uv_init_dir / "bitbucket-pipelines.yml" ).read_text ()
839861
840862 @pytest .mark .usefixtures ("_vary_network_conn" )
841- def test_coverage_notice (
863+ def test_coverage_integration (
842864 self , uv_init_dir : Path , capfd : pytest .CaptureFixture [str ]
843865 ):
844866 with change_cwd (uv_init_dir ):
@@ -968,7 +990,7 @@ def test_remove(self, uv_init_dir: Path, capfd: pytest.CaptureFixture[str]):
968990 "✔ Removing 'Test on 3.12' from default pipeline in 'bitbucket-pipelines.yml'.\n "
969991 "✔ Adding cache 'uv' definition to 'bitbucket-pipelines.yml'.\n "
970992 "✔ Removing pytest config from 'pyproject.toml'.\n "
971- "✔ Removing dependencies 'pytest', 'pytest-cov ' from the 'test' group in 'pyproject.toml'.\n "
993+ "✔ Removing dependency 'pytest' from the 'test' group in 'pyproject.toml'.\n "
972994 "✔ Removing '/tests'.\n "
973995 ).replace ("\n " , "" ).replace (" " , "" )
974996 contents = (uv_init_dir / "bitbucket-pipelines.yml" ).read_text ()
@@ -997,6 +1019,27 @@ def test_remove(self, uv_init_dir: Path, capfd: pytest.CaptureFixture[str]):
9971019"""
9981020 )
9991021
1022+ def test_coverage_integration (
1023+ self , uv_init_dir : Path , capfd : pytest .CaptureFixture [str ]
1024+ ):
1025+ with change_cwd (uv_init_dir ):
1026+ # Arrange
1027+ with usethis_config .set (quiet = True ):
1028+ use_coverage ()
1029+ use_pytest ()
1030+
1031+ # Act
1032+ use_pytest (remove = True )
1033+
1034+ # Assert
1035+ out , _ = capfd .readouterr ()
1036+ assert out == (
1037+ "✔ Removing pytest config from 'pyproject.toml'.\n "
1038+ "✔ Removing dependencies 'pytest', 'pytest-cov' from the 'test' group in \n 'pyproject.toml'.\n "
1039+ "✔ Removing '/tests'.\n "
1040+ "☐ Run 'coverage help' to see available coverage commands.\n "
1041+ )
1042+
10001043
10011044class TestRuff :
10021045 class TestAdd :
0 commit comments