From eaa815bc5a9fb69a38786313bf32ad9c79323998 Mon Sep 17 00:00:00 2001 From: Joe Lombrozo Date: Fri, 9 Sep 2022 13:16:06 -0400 Subject: [PATCH] fix some tests, make them crossplatform --- tests/test_api.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/tests/test_api.py b/tests/test_api.py index 1468a13..30ac6b8 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -4,6 +4,7 @@ import os import shutil from contextlib import suppress +from pathlib import Path import log import pytest @@ -74,7 +75,7 @@ def config(): os.makedirs(TMP) os.chdir(TMP) - os.system("touch .git") + Path(".git").touch() config = Config(root=TMP) config.datafile.text = CONFIG config.datafile.load() @@ -258,20 +259,20 @@ def it_should_create_links(config_with_link): expect(os.listdir()).contains("my_link") def it_should_not_overwrite_files(config_with_link): - os.system("touch my_link") + Path("my_link").touch() with pytest.raises(RuntimeError): gitman.install(depth=1) def it_should_not_overwrite_non_empty_directories(config_with_link): - os.system("mkdir my_link") - os.system("touch mylink/my_link") + os.mkdir("my_link") + Path("my_link/my_link").touch() with pytest.raises(RuntimeError): gitman.install(depth=1) def it_overwrites_files_with_force(config_with_link): - os.system("touch my_link") + Path("my_link").touch() expect(gitman.install(depth=1, force=True)) == True @@ -307,20 +308,20 @@ def it_should_create_links(config_with_links): expect(os.listdir()).contains("gmd_4") def it_should_not_overwrite_files(config_with_links): - os.system("touch gmd_3") + Path("gmd_3").touch() with pytest.raises(RuntimeError): gitman.install(depth=1) def it_should_not_overwrite_non_empty_directories(config_with_links): - os.system("mkdir gmd_3") - os.system("touch gmd_3/my_link") + os.mkdir("gmd_3") + Path("gmd_3/my_link").touch() with pytest.raises(RuntimeError): gitman.install(depth=1) def it_overwrites_files_with_force(config_with_links): - os.system("touch gmd_3") + Path("gmd_3").touch() expect(gitman.install(depth=1, force=True)) == True