Skip to content

Commit c4cbf6d

Browse files
committed
tests: reset permissions on tmp-path
to facilitate cleanup
1 parent e7b0e32 commit c4cbf6d

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

tests/test_log_setup.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -113,18 +113,21 @@ def test_set_loggers_Filehandler_without_permission(tmp_path):
113113
orig_handlers = logger.handlers
114114
logger.handlers = []
115115

116-
tmp_path.chmod(0o400)
117-
logfile = tmp_path / "logs/ft_logfile.log"
118-
config = {
119-
"verbosity": 2,
120-
"logfile": str(logfile),
121-
}
122-
123-
setup_logging_pre()
124-
with pytest.raises(OperationalException):
125-
setup_logging(config)
126-
127-
logger.handlers = orig_handlers
116+
try:
117+
tmp_path.chmod(0o400)
118+
logfile = tmp_path / "logs/ft_logfile.log"
119+
config = {
120+
"verbosity": 2,
121+
"logfile": str(logfile),
122+
}
123+
124+
setup_logging_pre()
125+
with pytest.raises(OperationalException):
126+
setup_logging(config)
127+
128+
logger.handlers = orig_handlers
129+
finally:
130+
tmp_path.chmod(0o700)
128131

129132

130133
@pytest.mark.skip(reason="systemd is not installed on every system, so we're not testing this.")

0 commit comments

Comments
 (0)