Skip to content

Add option to use different reference arrays for derived test classes #53

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

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

Conversation

csaluski
Copy link

Previously tests could not be inherited from classes in a way that let each class save its own array. This change makes the file written use the full test name, including the class name, instead of just the test name within the class.


This use case came up in a project I'm working on right now. The overall use case is to create a base class with tests that use class variables (It must not start with Test or Pytest will try to run its tests directly), then derive new Test classes from that class with different data. This is a normal Pytest workflow, but before this change Arraydiff would use the same name for each saved array, see the failing test case. It does not change default behavior, and adds this behavior when the "derive_classes" kwarg is added to the Arraydiff mark.

I think this change is nearly complete, but it might be worth revising the naming convention. I also notice that the Windows CI tests currently fail in a way that I haven't been able to diagnose, I'd appreciate some help figuring fixing those.

Previously tests could not be inherited from classes in a way that let each class save its own array. This change makes the file written use the full test name, including the class name, instead of just the test name within the class.
@pllim
Copy link
Member

pllim commented May 21, 2025

Thanks. I noticed that CI was disabled due to inactivity. I just re-enabled it but will have to close/reopen to trigger. Please do not be alarmed.

@pllim pllim closed this May 21, 2025
@pllim pllim reopened this May 21, 2025

def test_derived_fails():

tmpdir = tempfile.mkdtemp()
Copy link
Member

Choose a reason for hiding this comment

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

Can probably just use tmp_path fixture? https://docs.pytest.org/en/stable/how-to/tmp_path.html

@pllim pllim requested a review from astrofrog May 21, 2025 17:03
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