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

Reorganize the tests into unit/functional/integration/external #1155

Merged
merged 37 commits into from
Nov 23, 2023

Conversation

mwouts
Copy link
Owner

@mwouts mwouts commented Nov 7, 2023

This is very much a work in progress for now.
I'll try to classify all the different tests.
Will close #1136.

@mwouts mwouts self-assigned this Nov 7, 2023
Copy link

codecov bot commented Nov 7, 2023

Codecov Report

Merging #1155 (3fcc046) into main (4b56512) will increase coverage by 1.96%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #1155      +/-   ##
==========================================
+ Coverage   93.12%   95.08%   +1.96%     
==========================================
  Files          29       29              
  Lines        4419     4418       -1     
==========================================
+ Hits         4115     4201      +86     
+ Misses        304      217      -87     
Files Coverage Δ
src/jupytext/parse_version.py 100.00% <100.00%> (+80.00%) ⬆️

... and 10 files with indirect coverage changes

📣 Codecov offers a browser extension for seamless coverage viewing on GitHub. Try it in Chrome or Firefox today!

@mwouts
Copy link
Owner Author

mwouts commented Nov 9, 2023

Hi @LecrisUT , were you thinking of something like the current PR? You also suggested to add pytest markers I guess? And maybe it would be good to check that the test dependencies I have described at 30bd073 are indeed correct - is this something you expect to see on the CI in some way?

@mwouts mwouts force-pushed the reorganize_tests branch 2 times, most recently from 54ea28e to ff68ecd Compare November 11, 2023 22:41
@mwouts mwouts changed the title WIP Reorganize tests Reorganize the tests into unit/integration/functional Nov 11, 2023
@LecrisUT
Copy link
Contributor

Sorry, had a long week, I have a few notes, let me get to my PC later today and I'll write them out

@mwouts
Copy link
Owner Author

mwouts commented Nov 12, 2023

No worries at all! Take your time! This can as well be later on this week or next week-end. Thanks!

Copy link
Contributor

@LecrisUT LecrisUT left a comment

Choose a reason for hiding this comment

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

Sorry for the late review. Overall 👍 just 2 things to addressed in this PR:

  • Where to put the black, etc. dependencies. test-integration or test-external. Having them in test_functional might be a bit complicated for packaging
  • Using other methods to pytest.skip

pyproject.toml Outdated
Comment on lines 61 to 72
"autopep8",
"black",
"isort",
"flake8",
# jupytext --execute
"ipykernel",
# Pre-commit tests
"gitpython",
"pre-commit",
# Interaction with other contents managers
# jupyter-fs==0.4.0 is async, which is not supported by Jupytext ATM
"jupyter-fs<0.4.0"
Copy link
Contributor

Choose a reason for hiding this comment

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

I would prefer thse in an integration test, mostly because these are optional dependencies, and they primarily test how jupytext interacts with other tools. Indeed the tests are better classified as functional tests, and I see many projects do so, so it is more of a subjective classification.

Why I would prefer this as integration is because w.r.t. packaging, unit and functional tests are good to include as a whole, while integration tests are a bit hit-and-miss (mostly because most projects use mocking for these, and the package versions can differ drastically with the one tested upstream).

We could also move these to test-external as the optional-dependency (those that are optional) and keep the unit/integration/functional` categorization like this.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Thanks for the guidance! Actually I have moved all the tests that involve a non-core dependency to tests/external.

All the tests in unit, functional and integration pass, with very little dependencies. I think all these tests should always pass.

I have also included the tests in the package (but I was not sure whether tests/external should be included too?)

Copy link
Contributor

Choose a reason for hiding this comment

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

About packaging, yes it is better to be safe and include everything. Also, sdist only picks up on git sources (non-git sources are added as artifacts), and the only other one in the list is demo which is good to include as well

Copy link
Contributor

@LecrisUT LecrisUT Nov 20, 2023

Choose a reason for hiding this comment

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

About the tests 👍 to the organization. Just a comment, probably you are aware of the practice of mirroring the source files with the test files, but that is only meaningful in unit-tests, which you seem to be following, so 👍. Also, a coding practice tip, it is good to split the codecov flags into unit-test and the rest.

There is one confusing part, why areall of the tests as python packages? Pytest should automatically resolve them from the test_* naming scheme.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Thanks @LecrisUT !

Can you point me to an exemple re the differentiated coverage ?

Re the inits in tests, indeed I am planning to remove them in this PR. Right now I need them because they import from utils.py but I do plan to use fixtures instead of list_notebooks.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Owner Author

Choose a reason for hiding this comment

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

Nice! Thanks for sharing! I'll try this asap.

pyproject.toml Outdated Show resolved Hide resolved
pyproject.toml Outdated Show resolved Hide resolved
tests/conftest.py Outdated Show resolved Hide resolved
tests/conftest.py Show resolved Hide resolved
tests/functional/cli/test_black.py Outdated Show resolved Hide resolved
tests/functional/cli/test_cli.py Outdated Show resolved Hide resolved
unit and functional (and even integration) tests run with very little dependencies
@mwouts mwouts changed the title Reorganize the tests into unit/integration/functional Reorganize the tests into unit/functional/integration/external Nov 19, 2023
@@ -0,0 +1,50 @@
name: test-categories
Copy link
Contributor

Choose a reason for hiding this comment

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

These need to be added to .github/workflows/ci.yaml.
Also, remind me to make a PR to re-organize these CI files.

@LecrisUT
Copy link
Contributor

About the conda test failure, it seems you need to add a browser in the relevant packages.json

@mwouts
Copy link
Owner Author

mwouts commented Nov 23, 2023

Thanks @LecrisUT for guiding me into this! I am very glad with the outcome.

I've set up the coverage flags:
image

Also the coverage seems to go up (but I would like to see codecov commenting on this PR too!)
image

Also, remind me to make a PR to re-organize these CI files.

Thanks, they are all yours!

@mwouts mwouts merged commit 923798e into main Nov 23, 2023
23 of 25 checks passed
@mwouts mwouts deleted the reorganize_tests branch November 23, 2023 21:38
@mwouts
Copy link
Owner Author

mwouts commented Nov 23, 2023

@kloczek I know from #906 that the tests/packaging matter to you. We have recently changed both the packaging and the tests, would you mind to have a look and let us know if everything seems alright to you?

@kloczek
Copy link

kloczek commented Nov 24, 2023

@kloczek I know from #906 that the tests/packaging matter to you. We have recently changed both the packaging and the tests, would you mind to have a look and let us know if everything seems alright to you?

No problem. 😄
Jut please let me know what you want to me to test?

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.

Split tests into unit, integration, functional
3 participants