Skip to content

Commit 0eabf4f

Browse files
committed
test(make): Move file deletion to a fixture
1 parent 74678c5 commit 0eabf4f

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

test/t/test_make.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,23 @@
66

77

88
class TestMake:
9+
@pytest.fixture
10+
def remove_extra_makefile(self, bash):
11+
yield
12+
os.remove(f"{bash.cwd}/make/extra_makefile")
13+
914
@pytest.mark.complete("make -f Ma", cwd="make")
1015
def test_1(self, completion):
1116
assert completion == "kefile"
1217

1318
@pytest.mark.complete("make .", cwd="make", require_cmd=True)
14-
def test_2(self, bash, completion):
19+
def test_2(self, bash, completion, remove_extra_makefile):
1520
"""Hidden targets."""
1621
assert completion == ".cache/ .test_passes".split()
17-
os.remove(f"{bash.cwd}/make/extra_makefile")
1822

1923
@pytest.mark.complete("make .cache/", cwd="make", require_cmd=True)
20-
def test_3(self, bash, completion):
24+
def test_3(self, bash, completion, remove_extra_makefile):
2125
assert completion == ".cache/1 .cache/2".split()
22-
os.remove(f"{bash.cwd}/make/extra_makefile")
2326

2427
@pytest.mark.complete("make ", cwd="shared/empty_dir")
2528
def test_4(self, completion):
@@ -30,24 +33,20 @@ def test_5(self, completion):
3033
assert completion
3134

3235
@pytest.mark.complete("make ", cwd="make", require_cmd=True)
33-
def test_6(self, bash, completion):
36+
def test_6(self, bash, completion, remove_extra_makefile):
3437
assert completion == "all clean extra_makefile install sample".split()
35-
os.remove(f"{bash.cwd}/make/extra_makefile")
3638

3739
@pytest.mark.complete("make .cache/.", cwd="make", require_cmd=True)
38-
def test_7(self, bash, completion):
40+
def test_7(self, bash, completion, remove_extra_makefile):
3941
assert completion == ".cache/.1 .cache/.2".split()
40-
os.remove(f"{bash.cwd}/make/extra_makefile")
4142

4243
@pytest.mark.complete("make -C make ", require_cmd=True)
43-
def test_8(self, bash, completion):
44+
def test_8(self, bash, completion, remove_extra_makefile):
4445
assert completion == "all clean extra_makefile install sample".split()
45-
os.remove(f"{bash.cwd}/make/extra_makefile")
4646

4747
@pytest.mark.complete("make -nC make ", require_cmd=True)
48-
def test_8n(self, bash, completion):
48+
def test_8n(self, bash, completion, remove_extra_makefile):
4949
assert completion == "all clean extra_makefile install sample".split()
50-
os.remove(f"{bash.cwd}/make/extra_makefile")
5150

5251
@pytest.mark.complete("make -", require_cmd=True)
5352
def test_9(self, completion):

0 commit comments

Comments
 (0)