88from _pytask .git import init_repo
99from pytask import ExitCode
1010from pytask import cli
11- from pytask import storage
1211from tests .conftest import enter_directory
1312
14- _PROJECT_TASK = """
15- import pytask
16- from pathlib import Path
1713
18- def task_write_text(path = Path("in.txt"), produces = Path("out.txt")):
19- produces.write_text("a")
20- """
21-
22-
23- _PROJECT_TASK_NEW_INTERFACE = """
24- import pytask
25- from pathlib import Path
26-
27- def task_write_text(path=Path("in.txt"), produces=Path("out.txt")):
28- produces.write_text("a")
29- """
30-
31-
32- @pytest .fixture (params = [_PROJECT_TASK , _PROJECT_TASK_NEW_INTERFACE ])
33- def project (request , tmp_path ):
14+ @pytest .fixture
15+ def project (tmp_path ):
3416 """Create a sample project to be cleaned."""
35- tmp_path .joinpath ("task_module.py" ).write_text (textwrap .dedent (request .param ))
17+ content = """
18+ import pytask
19+ from pathlib import Path
20+
21+ def task_write_text(path=Path("in.txt"), produces=Path("out.txt")):
22+ produces.write_text("a")
23+ """
24+ tmp_path .joinpath ("task_module.py" ).write_text (textwrap .dedent (content ))
3625 tmp_path .joinpath ("in.txt" ).touch ()
3726
3827 tmp_path .joinpath ("to_be_deleted_file_1.txt" ).touch ()
@@ -42,28 +31,17 @@ def project(request, tmp_path):
4231 return tmp_path
4332
4433
45- _GIT_PROJECT_TASK = """
46- import pytask
47- from pathlib import Path
48-
49- def task_write_text(path = Path("in_tracked.txt"), produces = Path("out.txt")):
50- produces.write_text("a")
51- """
52-
53-
54- _GIT_PROJECT_TASK_NEW_INTERFACE = """
55- import pytask
56- from pathlib import Path
57-
58- def task_write_text(path=Path("in_tracked.txt"), produces=Path("out.txt")):
59- produces.write_text("a")
60- """
61-
62-
63- @pytest .fixture (params = [_GIT_PROJECT_TASK , _GIT_PROJECT_TASK_NEW_INTERFACE ])
64- def git_project (request , tmp_path ):
34+ @pytest .fixture
35+ def git_project (tmp_path ):
6536 """Create a sample project to be cleaned."""
66- tmp_path .joinpath ("task_module.py" ).write_text (textwrap .dedent (request .param ))
37+ content = """
38+ import pytask
39+ from pathlib import Path
40+
41+ def task_write_text(path=Path("in_tracked.txt"), produces=Path("out.txt")):
42+ produces.write_text("a")
43+ """
44+ tmp_path .joinpath ("task_module.py" ).write_text (textwrap .dedent (content ))
6745 tmp_path .joinpath ("in_tracked.txt" ).touch ()
6846 tmp_path .joinpath ("tracked.txt" ).touch ()
6947
@@ -83,11 +61,9 @@ def test_clean_database_ignored(project, runner):
8361 with enter_directory (project ):
8462 result = runner .invoke (cli , ["build" ])
8563 assert result .exit_code == ExitCode .OK
86- storage .create ()
8764 result = runner .invoke (cli , ["clean" ])
8865 assert result .exit_code == ExitCode .OK
8966
90- assert result .exit_code == ExitCode .OK
9167 text_without_linebreaks = result .output .replace ("\n " , "" )
9268 assert "to_be_deleted_file_1.txt" in text_without_linebreaks
9369 assert "to_be_deleted_file_2.txt" in text_without_linebreaks
0 commit comments