Skip to content

add support for passing valid unittest options to test suite#3790

Merged
boegel merged 3 commits intoeasybuilders:developfrom
Flamefire:test-suite-improvements
Jul 1, 2025
Merged

add support for passing valid unittest options to test suite#3790
boegel merged 3 commits intoeasybuilders:developfrom
Flamefire:test-suite-improvements

Conversation

@Flamefire
Copy link
Contributor

@Flamefire Flamefire commented Jul 30, 2021

Running the suite now allows to pass any valid unittest args, such as -k for filtering or --verbose for more detailed output (really missed that in #3780) similar to easybuilders/easybuild-easyconfigs@17379db in the EC repo

See also #4188 (previously contained here, not anymore but might cause simple conflicts)

The added else-branch added to each test suite/file are to support the "old way" of selecting tests as requested at #3790 (comment)
IMO the unittest style filtering is more powerful and the transition easy: python3 -m test.framework.modules load becomes python3 -m test.framework.modules -k load but some might rely on the current behavior so we can keep it for now

@Flamefire
Copy link
Contributor Author

I remember something about 9d04087
The "proper" way just marks the test as skipped and hence is no longer caught by the filtered output check. I.e. previously if a test was skipped it would print something to stdout which the later check would find and fail CI. This no longer works (this way).

So maybe the check should look for skipped tests? Or just ignore this for now...

@Flamefire Flamefire force-pushed the test-suite-improvements branch from 095ed85 to fb96f85 Compare September 21, 2021 07:16
@boegel boegel modified the milestones: 4.5.0, release after 4.5.0 Oct 13, 2021
@boegel
Copy link
Member

boegel commented Nov 13, 2021

These changes break the way we're currently filtering tests from test.framework.suite, which we should try and avoid:

$ python3 -m test.framework.suite load
E
======================================================================
ERROR: load (unittest.loader._FailedTest)
----------------------------------------------------------------------
AttributeError: module '__main__' has no attribute 'load'

----------------------------------------------------------------------
Ran 1 test in 0.000s

FAILED (errors=1)

This is supposed to filter all tests down to just the ones that include load in the test name...

@Flamefire
Copy link
Contributor Author

Flamefire commented Nov 13, 2021

These changes break the way we're currently filtering tests from test.framework.suite, which we should try and avoid:

But they allow the proper way: python3 -m test.framework.suite -k load should work which it did not before especially for the non-standard way of adding subtests. See e.g. 4e0a269

Edit: BTW: The failing test is due to a faulty usage env_file = open(reprod_dumpenv, "r").read().
Replace this by read_file to avoid the resource leak (missing close for open)

@boegel
Copy link
Member

boegel commented Nov 15, 2021

These changes break the way we're currently filtering tests from test.framework.suite, which we should try and avoid:

But they allow the proper way: python3 -m test.framework.suite -k load should work which it did not before especially for the non-standard way of adding subtests. See e.g. 4e0a269

OK, but can we somehow automagically translate python3 -m test.framework.suite load to python3 -m test.framework.suite -k load, to ensure both work?

Many people are used to filtering tests by just passing a pattern, and this still works for the individual subsuites:

python3 -m test.framework.modules load

(so does -k load here)

@Flamefire
Copy link
Contributor Author

OK, but can we somehow automagically translate python3 -m test.framework.suite load to python3 -m test.framework.suite -k load, to ensure both work?

Not sure. I'm afraid that would be hacky and could be ambiguous and/or break things. As far as I can tell this way now is the "correct" way (i.e. as documented by unittest) so if people now have to pass an additional -k I guess they'll manage ;) How many are running the EB test suite anyway? And if we have to decide between having access to (all) the regular unittest flags or this little backwards compat thing I'd say the change is well worth it

@boegel boegel modified the milestones: 4.5.1, release after 4.5.1 Dec 7, 2021
@boegel boegel modified the milestones: 4.5.2, release after 4.5.2 Jan 14, 2022
@boegel boegel modified the milestones: 4.5.3, release after 4.5.3 Feb 8, 2022
@Flamefire Flamefire force-pushed the test-suite-improvements branch from afe9f94 to d3eee12 Compare April 16, 2024 08:06
@Flamefire Flamefire force-pushed the test-suite-improvements branch from dfc4cc2 to 40afb37 Compare April 25, 2024 13:08
@Flamefire Flamefire force-pushed the test-suite-improvements branch from 40afb37 to 86fea8b Compare June 6, 2024 11:58
@boegel boegel modified the milestones: 4.9.2, release after 4.9.2 Jun 6, 2024
@Flamefire Flamefire force-pushed the test-suite-improvements branch from 86fea8b to 04eafd3 Compare August 8, 2024 07:32
@boegel boegel modified the milestones: 4.9.3, release after 4.9.3 Aug 28, 2024
@Flamefire Flamefire force-pushed the test-suite-improvements branch from 04eafd3 to 5c74dd0 Compare March 4, 2025 16:32
@Flamefire
Copy link
Contributor Author

Rebased this and the other PR. I just ran again in a case where I would have wanted to use e.g. -v

I found a way to support the current test filtering: If the 2nd argument starts with a dash the new method is used, otherwise the old one. So when using unittest you can do python -m test.framework.suite -v -k '*robot*' and also python -m test.framework.suite robot to use the "old" filtering only

@boegel boegel modified the milestones: release after 4.9.4, release after 5.0.0 Mar 17, 2025
@Flamefire Flamefire force-pushed the test-suite-improvements branch 2 times, most recently from 150d77c to b3caf72 Compare March 20, 2025 16:40
@Flamefire Flamefire force-pushed the test-suite-improvements branch 3 times, most recently from 769f6f6 to 2033d0f Compare June 26, 2025 10:04
@Flamefire Flamefire force-pushed the test-suite-improvements branch from 2033d0f to 5fa44f2 Compare June 26, 2025 10:07
@Flamefire Flamefire force-pushed the test-suite-improvements branch from 5fa44f2 to 9623fe6 Compare June 26, 2025 10:09
@boegel boegel changed the title Test suite improvements add support for passing valid unittest options to test suite Jul 1, 2025
Copy link
Member

@boegel boegel left a comment

Choose a reason for hiding this comment

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

lgtm

@boegel boegel merged commit dfac950 into easybuilders:develop Jul 1, 2025
37 checks passed
@Flamefire Flamefire deleted the test-suite-improvements branch July 1, 2025 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants