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

Ensure all produced files from tests are in a temp dir #239

Merged
merged 4 commits into from
Sep 29, 2021

Conversation

CasperWA
Copy link
Collaborator

@CasperWA CasperWA commented Sep 28, 2021

Description:

Closes #220.

Add pytest fixtures for loading EMMO, as this is done in several tests.
Add fixture for location to repo_dir, instantiating it only once per pytest session.
Add a yield-fixture for creating a temporary directory that lives for the lifetime of the test function.

This removes the possibility to check through the generated files from the tests, keeping the unit tests being just that: unit tests.
However, I guess the generated files should be tested more now?

In short, the unit tests here should never rely on human inspection, hence, they shouldn't produce any permanent files.

If examples are the motive for the tests (as it is explicitly stated for one of them) it should be added to the examples/ folder and be part of the documentation.

Type of change:

  • Bug fix.
  • New feature.
  • Documentation update.

Checklist:

This checklist can be used as a help for the reviewer.

  • Is the code easy to read and understand?
  • Are comments for humans to read, not computers to disregard?
  • Does a new feature has an accompanying new test (in the CI or unit testing schemes)?
  • Has the documentation been updated as necessary?
  • Does this close the issue?
  • Is the change limited to the issue?
  • Are errors handled for all outcomes?
  • Does the new feature provide new restrictions on dependencies, and if so is this documented?

Comments:

This partly closes the issue, since the tests should still be further tidied.

@CasperWA CasperWA changed the title Ensure all produced files are in a temp dir Ensure all produced files from tests are in a temp dir Sep 28, 2021
Add pytest fixtures for loading EMMO, as this is done in several tests.
Add fixture for location to repo_dir, instantiating it only once per
pytest session.
Add a yield-fixture for creating a temporary directory that lives for
the lifetime of the test function.
Change `emmo` to `ontopy` in MANIFEST.
@francescalb
Copy link
Collaborator

A lot of changes have been made here, not only ensuring that produced files do not persist after running pytest. I think most of them are cosmetic, but can we talk through them so I can learn a little here?

Copy link
Collaborator

@francescalb francescalb left a comment

Choose a reason for hiding this comment

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

I suggest loading emmo with get_emmo()

tests/conftest.py Outdated Show resolved Hide resolved
Co-authored-by: francescalb <48128015+francescalb@users.noreply.github.com>
Copy link
Collaborator

@francescalb francescalb left a comment

Choose a reason for hiding this comment

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

Good

@CasperWA CasperWA merged commit 92cd815 into master Sep 29, 2021
@CasperWA CasperWA deleted the cwa/close-220-tidy-up-tests branch September 29, 2021 07:27
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.

Tidy up unittests
2 participants