Skip to content

Commit 17f8079

Browse files
committed
test: fix models cli test
1 parent c430e8b commit 17f8079

1 file changed

Lines changed: 22 additions & 1 deletion

File tree

autotest/test_models.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,7 @@ def test_registry_to_pooch_format(self, synced_registry):
430430
assert len(pooch_registry) == len(synced_registry.files)
431431

432432

433+
@pytest.mark.xdist_group("registry_cache")
433434
class TestCLI:
434435
"""Test CLI commands."""
435436

@@ -453,7 +454,7 @@ def test_cli_list_empty(self, capsys):
453454

454455
from modflow_devtools.models.__main__ import cmd_list
455456

456-
args = argparse.Namespace(verbose=False)
457+
args = argparse.Namespace(verbose=False, source=None, ref=None)
457458
cmd_list(args)
458459

459460
captured = capsys.readouterr()
@@ -526,6 +527,11 @@ def test_cli_copy(self, tmp_path):
526527
result = source.sync(ref=TEST_MODELS_REF)
527528
assert len(result.synced) == 1
528529

530+
# Invalidate cached default registry so it reloads with newly synced data
531+
import modflow_devtools.models
532+
533+
modflow_devtools.models._default_registry_cache = None
534+
529535
# Load registry and get first model name
530536
registry = _DEFAULT_CACHE.load(TEST_MODELS_SOURCE_NAME, TEST_MODELS_REF)
531537
assert len(registry.models) > 0
@@ -558,6 +564,11 @@ def test_cli_copy_nonexistent_model(self, tmp_path, capsys):
558564
result = source.sync(ref=TEST_MODELS_REF)
559565
assert len(result.synced) == 1
560566

567+
# Invalidate cached default registry so it reloads with newly synced data
568+
import modflow_devtools.models
569+
570+
modflow_devtools.models._default_registry_cache = None
571+
561572
# Try to copy nonexistent model
562573
import argparse
563574

@@ -586,6 +597,11 @@ def test_cli_cp_alias(self, tmp_path):
586597
result = source.sync(ref=TEST_MODELS_REF)
587598
assert len(result.synced) == 1
588599

600+
# Invalidate cached default registry so it reloads with newly synced data
601+
import modflow_devtools.models
602+
603+
modflow_devtools.models._default_registry_cache = None
604+
589605
# Load registry and get first model name
590606
registry = _DEFAULT_CACHE.load(TEST_MODELS_SOURCE_NAME, TEST_MODELS_REF)
591607
assert len(registry.models) > 0
@@ -619,6 +635,11 @@ def test_python_cp_alias(self, tmp_path):
619635
result = source.sync(ref=TEST_MODELS_REF)
620636
assert len(result.synced) == 1
621637

638+
# Invalidate cached default registry so it reloads with newly synced data
639+
import modflow_devtools.models
640+
641+
modflow_devtools.models._default_registry_cache = None
642+
622643
# Load registry and get first model name
623644
registry = _DEFAULT_CACHE.load(TEST_MODELS_SOURCE_NAME, TEST_MODELS_REF)
624645
assert len(registry.models) > 0

0 commit comments

Comments
 (0)