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

[Labels] Cannot specify Full-Class ordering from another file #50

Open
Joacchim opened this issue Aug 5, 2021 · 4 comments
Open

[Labels] Cannot specify Full-Class ordering from another file #50

Joacchim opened this issue Aug 5, 2021 · 4 comments
Labels
enhancement New feature or request

Comments

@Joacchim
Copy link

Joacchim commented Aug 5, 2021

Hello,

In order to order the tests of a personal project, I've attempted to order tests on the basis of files (or the classes within it), in order to keep the ordering specification short and concise. Note that I've also encountered issues ordering tests in a similar way to the documentation, by specifying a class name as the label.

Alas, it seems that is does not work this way (or is not intended to ?), as I only receive a Warning telling me that the mark is ignored, in light of the failure to match a node_id with the provided label.

Looking a bit into the code, I noticed that the code path handling Class-based dependencies has the constraint of containing exactly two :: strings, meaning that it must probably be a test-name from within a specific test-class.

I believe that it would be quite practical to be able to order tests relatively to test classes, not only from the same file, but also from other test files, as the documentation does not hint at the impossibility to do so.

Thank you for maintaining this piece of code, in hope that my feedback here may help the project and other users !

@mrbean-bremen
Copy link
Member

Just to be clear (I may nor understand the issue correctly):

  • you don't want to order tests inside a test module, but only the test modules themselves
  • you are using --order-scope=module
  • you don't want to put a full test name in the marker, but only the module path as a more convenient way

Is that correct, or do you mean something else?

@Joacchim
Copy link
Author

Joacchim commented Aug 6, 2021

  1. Actually if I could do both, that'd be ideal (sorry, I'm greedy, I know :D)
  2. I haven't been using the --order-scope option, as I wasn't sure it would fit my need, and didn't look too much into it yet
  3. Yes, the point is to keep the names as short as reasonably possible (as opposed to pytest-dependency which I've used and is particularly verbose on that point, but still allows depending on whole classes from another module)

@mrbean-bremen
Copy link
Member

Ok, --order-scope=module means that tests in different modules are not mixed. You can sort tests inside a module, but if you order against tests in other modules, that would just mean that the test modules would be sorted accordingly.
So, if you order against the test in another module without an --order-scope option (say using before), that single test would be moved before the test in the other module. With that option, all tests in the module would be excuted before the tests in the other module - as far as I understand, this is what you want.

I understand that you want to use just the module name as marker to achieve the same, but that could be a bit tricky. I'm not sure that I could get this working without breaking anything else without major refactorings. You wrote in the other issue that you already adapted the code and could make a PR - I would be interested in that!

@Joacchim
Copy link
Author

Joacchim commented Aug 6, 2021

I guess I should try again with --order-scope=module then, and see if it works as I wanted it to.

About my patch, alright, I'll open a Draft PR to discuss this tonight (it may not suit your intended design though, we'll see :D)

@mrbean-bremen mrbean-bremen added the enhancement New feature or request label Aug 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants