Skip to content

Commit

Permalink
fix some tests, make them crossplatform
Browse files Browse the repository at this point in the history
  • Loading branch information
djeebus committed Sep 9, 2022
1 parent 0e3522f commit eaa815b
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import os
import shutil
from contextlib import suppress
from pathlib import Path

import log
import pytest
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down

0 comments on commit eaa815b

Please sign in to comment.