Skip to content

Commit eaa815b

Browse files
committed
fix some tests, make them crossplatform
1 parent 0e3522f commit eaa815b

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

tests/test_api.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import os
55
import shutil
66
from contextlib import suppress
7+
from pathlib import Path
78

89
import log
910
import pytest
@@ -74,7 +75,7 @@ def config():
7475
os.makedirs(TMP)
7576
os.chdir(TMP)
7677

77-
os.system("touch .git")
78+
Path(".git").touch()
7879
config = Config(root=TMP)
7980
config.datafile.text = CONFIG
8081
config.datafile.load()
@@ -258,20 +259,20 @@ def it_should_create_links(config_with_link):
258259
expect(os.listdir()).contains("my_link")
259260

260261
def it_should_not_overwrite_files(config_with_link):
261-
os.system("touch my_link")
262+
Path("my_link").touch()
262263

263264
with pytest.raises(RuntimeError):
264265
gitman.install(depth=1)
265266

266267
def it_should_not_overwrite_non_empty_directories(config_with_link):
267-
os.system("mkdir my_link")
268-
os.system("touch mylink/my_link")
268+
os.mkdir("my_link")
269+
Path("my_link/my_link").touch()
269270

270271
with pytest.raises(RuntimeError):
271272
gitman.install(depth=1)
272273

273274
def it_overwrites_files_with_force(config_with_link):
274-
os.system("touch my_link")
275+
Path("my_link").touch()
275276

276277
expect(gitman.install(depth=1, force=True)) == True
277278

@@ -307,20 +308,20 @@ def it_should_create_links(config_with_links):
307308
expect(os.listdir()).contains("gmd_4")
308309

309310
def it_should_not_overwrite_files(config_with_links):
310-
os.system("touch gmd_3")
311+
Path("gmd_3").touch()
311312

312313
with pytest.raises(RuntimeError):
313314
gitman.install(depth=1)
314315

315316
def it_should_not_overwrite_non_empty_directories(config_with_links):
316-
os.system("mkdir gmd_3")
317-
os.system("touch gmd_3/my_link")
317+
os.mkdir("gmd_3")
318+
Path("gmd_3/my_link").touch()
318319

319320
with pytest.raises(RuntimeError):
320321
gitman.install(depth=1)
321322

322323
def it_overwrites_files_with_force(config_with_links):
323-
os.system("touch gmd_3")
324+
Path("gmd_3").touch()
324325

325326
expect(gitman.install(depth=1, force=True)) == True
326327

0 commit comments

Comments
 (0)