Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing state pollution in parser_cache #195

Merged
merged 2 commits into from Aug 25, 2021

Conversation

sturmianseq
Copy link
Contributor

This PR aims to improve test reliability of test test_permission_error by removing state pollution in parser_cache by calling method clear

The test can fail in this way by running pip3 install pytest-repeat; python3 -m pytest --count=2 test/test_ljson_mem.py::test_unique_check:

        monkeypatch.setattr(cache, '_save_to_file_system', save)
        with pytest.warns(Warning):
>           parse(path=__file__, cache=True, diff_cache=True)
E           Failed: DID NOT WARN. No warnings of type (<class 'Warning'>,) was emitted. The list of emitted warnings is: [].

It may be better to clean state pollutions so that some other tests won't fail in the future due to the shared state pollution.

Copy link
Collaborator

@isidentical isidentical left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks OK, though I'd prefer either a try/finally on the parse call or an explicit fixture that does something like this;

@pytest.fixture
def clear_cache():
    yield
    parser_cache.clear()

to make sure that we clear it in either way.

@davidhalter
Copy link
Owner

I agree with @isidentical

@sturmianseq
Copy link
Contributor Author

Thanks for your comment. The PR is updated with try & finally blocks applied.

@isidentical isidentical merged commit ae491cb into davidhalter:master Aug 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants