Skip to content

Commit f839167

Browse files
committed
Alternate test for failure path in rewrite that does not require us to ignore type checking.
1 parent cece6e7 commit f839167

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

tests/test_main.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@ def test_set_key_no_file(tmp_path):
2222
assert os.path.exists(nx_file)
2323

2424

25-
def test_set_key_invalid_file():
26-
with pytest.raises(TypeError):
27-
dotenv.set_key(None, "foo", "bar") # type: ignore
28-
29-
3025
@pytest.mark.parametrize(
3126
"before,key,value,expected,after",
3227
[
@@ -183,6 +178,13 @@ def test_unset_encoding(dotenv_file):
183178
assert f.read() == ""
184179

185180

181+
def test_set_key_unauthorized_file(dotenv_file):
182+
os.chmod(dotenv_file, 0o000)
183+
184+
with pytest.raises(PermissionError):
185+
dotenv.set_key(dotenv_file, "a", "x")
186+
187+
186188
def test_unset_non_existent_file(tmp_path):
187189
nx_file = str(tmp_path / "nx")
188190
logger = logging.getLogger("dotenv.main")

0 commit comments

Comments
 (0)