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 fixtures for Python3.7 #536

Conversation

CasperWA
Copy link
Collaborator

@CasperWA CasperWA commented Feb 3, 2023

Description:

Fix issue with fancy pytest fixtures for running the tools as a Python module for Python 3.7.

Basically, the fixtures have been reimplemented by splitting the single tool fixture into two separate fixtures:

  • get_tool: Import a tool as a module.
    Essentially, one uses this fixture in a test and then runs ontodoc = get_tool("ontodoc") to import the tools/ontodoc file as a module. It can now be tested by running its main() function.
  • rename_tools: Add a .py extension to all tools.
    This fixture runs prior to all tests in this module (the tests/tools/ folder). First, it adds a .py suffix to all the tool file names to make them importable as a module. Then it stops executing for a while (yields) and then all the tests can be run.
    Then after they're done it reverts the file names, by removing the .py suffix. Furthermore, it returns sys.path to its original state prior to running the tests; to make the imports of the tools work, the tools folder had to be added to the sys.path.

I updated the doc-strings for all the tests to be more clear about where the fixtures are coming from as well, and tried to minimize the imports outside the test functions as much as possible.

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:

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.

Excellent!

@francescalb francescalb merged commit ae3ec1c into flb/bypass_punning_in_ontodoc Feb 4, 2023
@francescalb francescalb deleted the cwa/test_flb/bypass_punning_in_ontodoc branch February 4, 2023 18:36
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