Skip to content

How to add config schemas in pytest (or avoid them altogether) #2261

Answered by Jasha10
hogru asked this question in Q&A
Discussion options

You must be logged in to vote

So, I guess the question is: What is the “equivalent” of cs.store() in the pytest context?

cs.store() should work the same way in the for initialize+compose as it does for @hydra.main.
The key is to make sure that you call cs.store before you call compose. I suspect that in your case, the call to cs.store is not being run.


If your call to cs.store is at the top level of my_configs.py, you could import the my_configs module in your pytest fixture. That should be enough to guarantee that the config_schema node get stored.

# my_configs.py
...
cs = ConfigStore.instance()
cs.store(name="config_schema", node=MyConfig)
...
# test_my_configs.py
...
@pytest.fixture
def hydra_config():
    import 

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@hogru
Comment options

@Jasha10
Comment options

Jasha10 Jun 11, 2022
Collaborator

@hogru
Comment options

@Jasha10
Comment options

Jasha10 Jun 26, 2022
Collaborator

Answer selected by hogru
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants