Teach sanity check in tests about temp dirs under HOME
On GitHub the RUNNER_TEMP dir is inside the user's home directory. I think the spirit of the check is making sure you aren't touching stuff like ~/.config/qutebrowser/ in the tests, if it's within a specified tempdir it should be fine
This commit is contained in:
parent
0c3807b04a
commit
cc85d61303
|
|
@ -10,6 +10,7 @@ import sys
|
|||
import contextlib
|
||||
import enum
|
||||
import argparse
|
||||
import tempfile
|
||||
from typing import Iterator, Optional, Dict
|
||||
|
||||
from qutebrowser.qt.core import QStandardPaths
|
||||
|
|
@ -311,14 +312,15 @@ def _create(path: str) -> None:
|
|||
0700. If the destination directory exists already the permissions
|
||||
should not be changed.
|
||||
"""
|
||||
if APPNAME == 'qute_test' and path.startswith('/home'): # pragma: no cover
|
||||
for k, v in os.environ.items():
|
||||
if k == 'HOME' or k.startswith('XDG_'):
|
||||
log.init.debug(f"{k} = {v}")
|
||||
raise AssertionError(
|
||||
"Trying to create directory inside /home during "
|
||||
"tests, this should not happen."
|
||||
)
|
||||
if APPNAME == 'qute_test':
|
||||
if path.startswith('/home') and not path.startswith(tempfile.gettempdir()): # pragma: no cover
|
||||
for k, v in os.environ.items():
|
||||
if k == 'HOME' or k.startswith('XDG_'):
|
||||
log.init.debug(f"{k} = {v}")
|
||||
raise AssertionError(
|
||||
"Trying to create directory inside /home during "
|
||||
"tests, this should not happen."
|
||||
)
|
||||
os.makedirs(path, 0o700, exist_ok=True)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue