Skip to content

Commit

Permalink
[MAINT] Prevent workers from trying to parse sys.argv upon intializat…
Browse files Browse the repository at this point in the history
…ion (#850)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
peytondmurray and pre-commit-ci[bot] authored Aug 2, 2024
1 parent 1df30a2 commit d88410f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ test-results
.ruff_cache

# conda-store-ui
conda-store-server/conda_store_server/server/static/conda-store-ui/
conda-store-server/conda_store_server/_internal/server/static/conda-store-ui/

# Docusaurus dependencies
/node_modules
Expand Down
20 changes: 12 additions & 8 deletions conda-store-server/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,14 @@ def celery_config(tmp_path, conda_store):


@pytest.fixture
def conda_store_config(tmp_path, request):
def conda_store_config(tmp_path):
"""A conda store configuration fixture.
sys.path is manipulated so that only the name of the called program
(e.g. `pytest`) is present. This prevents traitlets from parsing any
additional pytest args as configuration settings to be applied to
the conda-store-server.
"""
from traitlets.config import Config

filename = tmp_path / ".conda-store" / "database.sqlite"
Expand All @@ -47,6 +54,9 @@ def conda_store_config(tmp_path, request):

storage.LocalStorage.storage_path = str(tmp_path / ".conda-store" / "storage")

original_sys_argv = list(sys.argv)
sys.argv = [sys.argv[0]]

with utils.chdir(tmp_path):
yield Config(
CondaStore=dict(
Expand All @@ -56,13 +66,7 @@ def conda_store_config(tmp_path, request):
)
)

original_sys_argv = list(sys.argv)
sys.argv = [sys.argv[0]]

def teardown():
sys.argv = list(original_sys_argv)

request.addfinalizer(teardown)
sys.argv = list(original_sys_argv)


@pytest.fixture
Expand Down

0 comments on commit d88410f

Please sign in to comment.