mirror of
https://github.com/adrienverge/yamllint.git
synced 2025-02-25 18:55:20 -06:00
tests: Delete env vars that could interfere
Several environment variables can influence which config file yamllint
chooses to use [1]. Before this change, if you set those environment
variables and ran “python -m unittest discover”, then you could cause
certain tests to use the wrong config file and fail.
Fixes #621.
[1]: <152ba20f33/yamllint/cli.py (L180-L188)
>
This commit is contained in:
parent
f3adc585d2
commit
92688d2bb0
@ -66,6 +66,26 @@ def utf8_available():
|
||||
return False
|
||||
|
||||
|
||||
def setUpModule():
|
||||
# yamllint uses these environment variables to find a config file.
|
||||
env_vars_that_could_interfere = (
|
||||
'YAMLLINT_CONFIG_FILE',
|
||||
'XDG_CONFIG_HOME',
|
||||
# These variables are used to determine where the user’s home
|
||||
# directory is. See
|
||||
# https://docs.python.org/3/library/os.path.html#os.path.expanduser
|
||||
'HOME',
|
||||
'USERPROFILE',
|
||||
'HOMEPATH',
|
||||
'HOMEDRIVE'
|
||||
)
|
||||
for name in env_vars_that_could_interfere:
|
||||
try:
|
||||
del os.environ[name]
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
|
||||
class CommandLineTestCase(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
|
Loading…
Reference in New Issue
Block a user