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

Add support for 'pytest' #249

Merged
merged 1 commit into from
Apr 21, 2021
Merged

Add support for 'pytest' #249

merged 1 commit into from
Apr 21, 2021

Conversation

anjensan
Copy link
Contributor

Minor test refactoring, fix some tests:

  • Move "test/{build => buildd}" (pytest ignores 'build' by default)
  • Copy 'example_project' to temp dir before each test
  • This PR does not migrate tests themselves - python -m unittest still works.

To run pytest:

> pip install pytest
> pytest

Test runner supports many nice features: printing logs --log-cli-level=DEBUG, printing local variables --showlocals, auto pdb --pdb etc. More details here: https://docs.pytest.org/en/stable/usage.html

Move "test/{build => buildd}" (pytest ignores 'build' by default)
Copy 'example_project' to temp dir before each test
Minor refactoring
mkdir(test_project_dir_path / '.dags')
(test_project_dir_path / '.dags' / 'leftover').touch()


def dags_leftovers_exist(test_project_dir_path: Path = TEST_PROJECT_PATH):
def dags_leftovers_exist(test_project_dir_path=None):
Copy link
Contributor

Choose a reason for hiding this comment

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

Why?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now 'TEST_PROJECT_PATH' is different for each test (tmp directory) and redefined in TestCase.setUp

@@ -31,7 +31,7 @@ class _BaseBuildReflectTest(
mixins.PrototypedDirMixin,
unittest.TestCase,
):
proto_dir = "build/bf-projects/bf_selfbuild_project"
proto_dir = "buildd/bf-projects/bf_selfbuild_project"
Copy link
Contributor

Choose a reason for hiding this comment

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

why buildd instead of build?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

'pytest' ignores 'build' and 'dist' directories by default. pytest-dev/pytest#1544
It might be "fixed" by redefining configuration for pytest in pyproject.toml OR by renaming directories.

@anjensan anjensan merged commit 4af43d1 into master Apr 21, 2021
@anjensan anjensan deleted the aj-support-pytest branch June 15, 2022 11: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.

3 participants