You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
tests: Move code for deleting env vars to __init__
The motivation behind this change is to make it easier to create a
future commit. That future commit will make yamllint change its behavior
if an environment variable named YAMLLINT_FILE_ENCODING is found. That
new environment variable will potentially cause interference with many
different tests.
Before this change, environment variables would only be deleted when the
tests.test_cli module was used. At the moment, it’s OK to do that
because that’s the only test module that will fail if certain
environment variables are set. Once yamllint is updated to look for the
YAMLLINT_FILE_ENCODING variable, pretty much every test will be likely
to fail if YAMLLINT_FILE_ENCODING is set to a certain values. This
change makes the code for deleting environment variables get run for all
tests (not just tests.test_cli).
As an alternative, we could have kept most of the code for deleting
environment variables in tests/test_cli.py, and only included code for
deleting YAMLLINT_FILE_ENCODING in tests/__init__.py. I decided to put
all of the environment variable deletion code in tests/__init__.py in
order to make things more consistent and easier to understand.
I had also considered adding a function for deleting environment
variables to tests/common.py and then adding this to every test module
that needs to have environment variables deleted:
from tests.common import remove_env_vars_that_might_interfere
setUpModule = remove_env_vars_that_might_interfere()
I decided to not do that because pretty much every single test module
will fail if YAMLLINT_FILE_ENCODING is set to certain values, and
there’s a lot of test modules.
0 commit comments