Skip to content

Commit

Permalink
Fix wrong variable name
Browse files Browse the repository at this point in the history
  • Loading branch information
pgiraud committed Dec 12, 2024
1 parent e942271 commit 546adcd
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions tests/test_hba.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ def test_hba_path(tmp_path):

hba = HBA()
assert hba.path is None
with pytest.raises(ValueError, match="No file-like object nor path provided"):
hba.save()

p = tmp_path / "filename"
hba = HBA([], p)
Expand Down Expand Up @@ -199,24 +201,24 @@ def test_parse_file(mocker, tmp_path):
mocker.patch("builtins.open", m)
except Exception:
mocker.patch("__builtin__.open", m)
pgpass = parse("filename")
pgpass.lines.append(HBAComment("# Something"))
hba = parse("filename")
hba.lines.append(HBAComment("# Something"))

assert m.called
pgpass.save()
hba.save()
handle = m()
handle.write.assert_called_with("# Something\n")

# Also works for other string types
m.reset_mock()
pgpass = parse("filename")
pgpass.lines.append(HBAComment("# Something"))
hba = parse("filename")
hba.lines.append(HBAComment("# Something"))
assert m.called

# Also works with path
m.reset_mock()
pgpass = parse(tmp_path / "filename")
pgpass.lines.append(HBAComment("# Something"))
hba = parse(tmp_path / "filename")
hba.lines.append(HBAComment("# Something"))

assert m.called

Expand Down

0 comments on commit 546adcd

Please sign in to comment.