Skip to content

Commit

Permalink
Further restric config file writing test
Browse files Browse the repository at this point in the history
  • Loading branch information
pvandyken committed Feb 20, 2024
1 parent 45ce959 commit 0c404d5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions snakebids/tests/test_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,19 @@ def test_writes_correct_format(self, ext: str, path: Path, mocker: MockerFixture
mocks["yamldump"].assert_called_once_with({}, path)

@allow_function_scoped
@given(path=st.text().filter(lambda s: Path(s) not in {Path(), Path("/")}))
@given(
path=st.text().filter(lambda s: Path(s).resolve() not in {Path(), Path("/")})
)
def test_doesnt_overwrite_file(self, path: str, fakefs: FakeFilesystem):
fakefs.reset()
fakefs.create_file(path)
with pytest.raises(FileExistsError, match="already exists"):
configio.write_config(path, {})

@allow_function_scoped
@given(path=st.text().filter(lambda s: Path(s) not in {Path(), Path("/")}))
@given(
path=st.text().filter(lambda s: Path(s).resolve() not in {Path(), Path("/")})
)
def test_overwrites_file_if_forced(
self, path: str, fakefs: FakeFilesystem, mocker: MockerFixture
):
Expand Down

0 comments on commit 0c404d5

Please sign in to comment.