tests: move create_empty_file() to conftest.py
This commit is contained in:
parent
78af0d86aa
commit
b80dd59352
|
@ -20,7 +20,7 @@ def test_expand_vars(patched_home_env):
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skipif(os.name != "posix", reason="Tests Posix (not Windows) permissions.")
|
@pytest.mark.skipif(os.name != "posix", reason="Tests Posix (not Windows) permissions.")
|
||||||
def test_has_expected_permissions_true(tmpdir):
|
def test_has_expected_permissions_true(tmpdir, create_empty_file):
|
||||||
file_name = f"{tmpdir}/test"
|
file_name = f"{tmpdir}/test"
|
||||||
|
|
||||||
create_empty_file(file_name)
|
create_empty_file(file_name)
|
||||||
|
@ -30,15 +30,10 @@ def test_has_expected_permissions_true(tmpdir):
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skipif(os.name != "posix", reason="Tests Posix (not Windows) permissions.")
|
@pytest.mark.skipif(os.name != "posix", reason="Tests Posix (not Windows) permissions.")
|
||||||
def test_has_expected_permissions_false(tmpdir):
|
def test_has_expected_permissions_false(tmpdir, create_empty_file):
|
||||||
file_name = f"{tmpdir}/test"
|
file_name = f"{tmpdir}/test"
|
||||||
|
|
||||||
create_empty_file(file_name)
|
create_empty_file(file_name)
|
||||||
os.chmod(file_name, 0o755)
|
os.chmod(file_name, 0o755)
|
||||||
|
|
||||||
assert not file_utils.has_expected_permissions(file_name, 0o700)
|
assert not file_utils.has_expected_permissions(file_name, 0o700)
|
||||||
|
|
||||||
|
|
||||||
def create_empty_file(file_name):
|
|
||||||
with open(file_name, "w"):
|
|
||||||
pass
|
|
||||||
|
|
|
@ -13,3 +13,12 @@ def patched_home_env(monkeypatch, tmpdir):
|
||||||
monkeypatch.setenv("HOME", str(tmpdir))
|
monkeypatch.setenv("HOME", str(tmpdir))
|
||||||
|
|
||||||
return tmpdir
|
return tmpdir
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def create_empty_file():
|
||||||
|
def inner(file_name):
|
||||||
|
with open(file_name, "w"):
|
||||||
|
pass
|
||||||
|
|
||||||
|
return inner
|
||||||
|
|
Loading…
Reference in New Issue