@@ -35,10 +35,11 @@ def test_sample_N():
3535 assert a == [2 , 3 , 1 , 2 ]
3636
3737
38- def test_download ():
38+ def test_download (tmp_path , monkeypatch ):
3939 from jcvi .apps .base import cleanup , download
4040 from jcvi .apps .vecscreen import ECOLI_URL , UNIVEC_URL
4141
42+ monkeypatch .chdir (tmp_path )
4243 ret = download ("http://www.google.com" )
4344 assert ret == "index.html"
4445 cleanup (ret )
@@ -83,10 +84,11 @@ def test_flatten(input_list, output_list):
8384 assert flatten (input_list ) == output_list
8485
8586
86- def test_cleanup ():
87+ def test_cleanup (tmp_path , monkeypatch ):
8788 from jcvi .apps .base import cleanup , mkdir
8889 from jcvi .formats .base import write_file
8990
91+ monkeypatch .chdir (tmp_path )
9092 write_file ("a" , "content_a" , skipcheck = True )
9193 write_file ("b" , "content_b" , skipcheck = True )
9294 write_file ("c" , "content_c" , skipcheck = True )
@@ -109,11 +111,11 @@ def test_cleanup():
109111 assert not op .exists (path )
110112
111113
112- def test_need_update ():
114+ def test_need_update (tmp_path , monkeypatch ):
113115 from jcvi .apps .base import cleanup , need_update
114116 from jcvi .formats .base import write_file
115117
116- cleanup ( "a" , "b" , "c" )
118+ monkeypatch . chdir ( tmp_path )
117119 assert need_update ("does_not_exist.txt" , "does_not_exist.txt" )
118120
119121 write_file ("a" , "content_a" , skipcheck = True )
@@ -130,7 +132,6 @@ def test_need_update():
130132 assert need_update (["c" , "b" ], "a" )
131133 assert not need_update ("a" , ["b" , "c" ])
132134 assert need_update (["a" , "b" ], ["c" , "d" ])
133- cleanup ("a" , "b" , "c" )
134135
135136
136137def test_set_image_options ():
@@ -155,9 +156,10 @@ def test_set_image_options():
155156 g .add_argument ("--group" , default = "jcvi" , help = "pytest coverage" )
156157
157158
158- def test_getpath ():
159+ def test_getpath (tmp_path , monkeypatch ):
159160 from jcvi .apps .base import getpath
160161
162+ monkeypatch .chdir (tmp_path )
161163 with mock .patch ("builtins.input" , lambda _ : "e\r vvvvvvvv = zzzzzzzz\n " ):
162164 assert getpath ("not-part-of-path" , name = "CLUSTALW2" , warn = "warn" ) is None
163165
0 commit comments