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

Refactor test_create, test_proxy, and test_env for test isolation #2416

Merged
merged 9 commits into from
Mar 29, 2023

Conversation

AntoinePrv
Copy link
Member

@AntoinePrv AntoinePrv commented Mar 28, 2023

Big PR, sorry. Basically it uses the new fixture to create temporary root_prefix and home directory inside a /tmp folder.

  • Deactivate PyCQA line-length warnings
  • Proper os.environ restore in pytest
  • Add --mamba-pkgs-dir for cache reuse in Pytest
  • Set pytest tmp retention policy
  • Allow Path in test helpers
  • Refactor test_create for isolation
  • Improve pytest fixtures
  • Refactor test_env.py for test isolation
  • Refactor test_proxy for isolating tests



def test_register_new_env(tmp_home, tmp_root_prefix):
helpers.create("-n", "env2", "--json", no_dry_run=True)
Copy link
Member

Choose a reason for hiding this comment

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

Do we remove the created test environments after the tests are done? It was handled by the teardown_class before... (This applies wherever create is used)

Copy link
Member Author

Choose a reason for hiding this comment

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

This is handled by the tmp_root_prefix fixture that sets a temporary root prefix for all environments.
It is created under temporary storage, independent for each test, and safely cleaned up afterwards.

Copy link
Member

Choose a reason for hiding this comment

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

Hmm yes, but it's not the case for the explicitly created envs env2, env3, etc. Is it?

Copy link
Member

@Hind-M Hind-M Mar 29, 2023

Choose a reason for hiding this comment

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

Oh ok I see, you mean that deleting the tmp_root_prefix deletes implicitely everything... ok!

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes exactly, the whole root_prefix is deleting, deleting everything with it

@AntoinePrv AntoinePrv requested a review from Hind-M March 29, 2023 14:41
@AntoinePrv AntoinePrv merged commit 05f1b9b into mamba-org:main Mar 29, 2023
@AntoinePrv AntoinePrv deleted the test-create branch March 29, 2023 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants