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

Fix one more test that pollutes the filesystem #1067

Merged
merged 1 commit into from
Aug 13, 2024

Conversation

rocky
Copy link
Member

@rocky rocky commented Aug 13, 2024

Ideally, we should be setting $InitialDirectory to $TempoarayDirectory as well. We should not be writing into $InitialDirectory which is not guaranteed to be writable.

@rocky rocky requested a review from mmatera August 13, 2024 10:17
@rocky rocky force-pushed the one-more-test-pollution-fix branch from be27d16 to 5730b16 Compare August 13, 2024 10:19
@mmatera
Copy link
Contributor

mmatera commented Aug 13, 2024

Ideally, we should be setting $InitialDirectory to $TempoarayDirectory as well. We should not be writing into $InitialDirectory which is not guaranteed to be writable.

This could be done inside test.helper.reset_session :

def reset_session(add_builtin=True, catch_interrupt=False ):
    global session
    session.reset()
    session.evaluate('SetDirectory["/tmp"] ')    # <<  add me

Then, by adding

(None, None, None, None)

as the first "test" in the @pytest.mark.parametrize list, we avoid possible side effects from definitions introduced in other tests.

@rocky
Copy link
Member Author

rocky commented Aug 13, 2024

Ideally, we should be setting $InitialDirectory to $TempoarayDirectory as well. We should not be writing into $InitialDirectory which is not guaranteed to be writable.

This could be done inside test.helper.reset_session :

def reset_session(add_builtin=True, catch_interrupt=False ):
    global session
    session.reset()
    session.evaluate('SetDirectory["/tmp"] ')    # <<  add me

Then, by adding

(None, None, None, None)

as the first "test" in the @pytest.mark.parametrize list, we avoid possible side effects from definitions introduced in other tests.

Probably more simply done as a setup_function() of pytest. See https://docs.pytest.org/en/stable/how-to/xunit_setup.html

@mmatera
Copy link
Contributor

mmatera commented Aug 13, 2024

Ideally, we should be setting $InitialDirectory to $TempoarayDirectory as well. We should not be writing into $InitialDirectory which is not guaranteed to be writable.

This could be done inside test.helper.reset_session :

def reset_session(add_builtin=True, catch_interrupt=False ):
    global session
    session.reset()
    session.evaluate('SetDirectory["/tmp"] ')    # <<  add me

Then, by adding

(None, None, None, None)

as the first "test" in the @pytest.mark.parametrize list, we avoid possible side effects from definitions introduced in other tests.

Probably more simply done as a setup_function() of pytest. See https://docs.pytest.org/en/stable/how-to/xunit_setup.html

Probably it is, and it would be clearer than the "Null" tests... Let's do it in another round.

@rocky
Copy link
Member Author

rocky commented Aug 13, 2024

Probably it is, and it would be clearer than the "Null" tests... Let's do it in another round.

Ok. Please do it when you have time.

@rocky rocky merged commit e00f6e1 into master Aug 13, 2024
10 checks passed
@rocky rocky deleted the one-more-test-pollution-fix branch August 13, 2024 10:54
rocky added a commit that referenced this pull request Aug 13, 2024
As General Peron said, "Better than saying is doing". This is what I was
talking about in #1067.
Also, I improved some docstrings a little bit.

---------

Co-authored-by: rocky <[email protected]>
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.

2 participants