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

test: pytest scope to be function as tests might change server #1378

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

LennartPurucker
Copy link
Contributor

To make sure that each test runs on the test server by default, we need to change the scope to "function," as another test might overwrite this otherwise.

@eddiebergman Was there a reasons to set this to session?

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.23%. Comparing base (bf6d010) to head (14250d6).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1378      +/-   ##
===========================================
- Coverage    84.27%   84.23%   -0.04%     
===========================================
  Files           38       38              
  Lines         5315     5315              
===========================================
- Hits          4479     4477       -2     
- Misses         836      838       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@LennartPurucker
Copy link
Contributor Author

So it seems there was a reason because the tests are now failing, but whatever the reason, it broke other tests. So we need to re-implement the way this works

@eddiebergman
Copy link
Collaborator

eddiebergman commented Oct 18, 2024

I think I did session because when run in parallel with "function", where it will keep entering and exiting the fixture which sets and unsets the test server config, a global variable. This caused the tests to fail.

It's actually really hard to get around this since they all use the same config in parallel, where some tests want production and some want test server. In retro-spect, session doesn't make huge sense either, but it would essentially set the default to test server at the start which is most of them. Any production server tests however could change this global when they need to, but this then causes issues for the test server tests.

Possible high-level solutions are really:

  1. Sequential tests
  2. Somehow partition sets (complexity)
  3. All tests are test server
  4. Refactor all possible web functions to take in the global config
  5. Some locking mechanism on the tests (kind of a manual midway between 1. and 2.)
  6. Boxed parallel tests, I think there's some plugin somewhere that does this but it increases runtime. Essentially gives each test it's own interpreter session.

@PGijsbers
Copy link
Collaborator

re 2,5,6: basically just use a pytest marker and run one with "not production" and one with "production", and that is a fairly transparent way of dealing with this. That said, it's still not ideal but from the top of my head I am not aware of a good solution.

@PGijsbers
Copy link
Collaborator

I am a bit confused about this. Previously (with unittest) this was never an issue, yet they still referred to the same global variable.

@PGijsbers
Copy link
Collaborator

but tests pass for me locally and as far as I can tell the original issue this PR tries to address also doesn't occur when run on CI/CD: https://github.com/openml/openml-python/actions/runs/12274682764/job/34248109797?pr=1384

@PGijsbers
Copy link
Collaborator

I still don't fully understand by what miracle it does work though. Since all access is openml.config.server one really would expect changing this from anywhere should affect its usage everywhere else..

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.

4 participants