-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Giving file_or_dir
twice collects tests twice
#1187
Comments
Thanks for the report @htgoebel! I had used this behavior of collecting tests more than once from the command-line in order to run the same test multiple times to track down some flaky behavior, but I think my use-case is a little contrived and yours makes more sense IMO. Any more thoughts, @hpk42 @RonnyPfannschmidt @The-Compiler? |
I usually do something like I don't really have an opinion on this, I can find arguments for and against both behaviours, and I'd be fine with both. |
don't have a strong opinion either but if in doubt i'd rather not change the default and better introduce a |
I'm for the plugin solution |
Plugin sounds complicated. So I'm for a plugin |
a propperly separate |
Making a plugin is actually really easy using the cookiecutter-pytest-plugin, in fact just made one myself to quickly see it in action. @htgoebel, could you try it out? If all is well I will publish it to PyPI, it still needs more tests and README. To install it use:
No other configuration is necessary. |
i'm closing this as working as intended given that @nicoddemus already finished a plugin |
Btw kudos to @hackebrot, it took me 10 minutes to have that plugin working, well done! cookiecutter-pytest-plugin makes it really simple to create new plugins, covering a lot of the boiler plate of setting up a new repository, setup.py, C.I., etc etc. Highly recommended. 👍 |
@nicoddemus The plugin does not show any effect here. I still get duplicates. |
Can you show me the output of a sample session? |
It is the same as in my very fist comment here. I used
|
Thank you @nicoddemus! 🙇 Happy to hear that 😸 |
@htgoebel hmm that's strange. I will investigate this later (most probably tomorrow). I moved over this discussion over to nicoddemus/pytest-drop-dup-tests#2 |
Just came up against this problem, I'm confused why this functionality has to be placed into a separate plugin, why can't it be submitted as a |
Mostly because it is a behavior change and no one seemed to have a strong opinion for it... the change is trivial, as the plugin demonstrates. If more people are in favor of changing the behavior, I would gladly merge it into the core. 😄 |
Ah okay. I'm struggling to think of a scenario where allowing duplicates would be considered an advantage. Can someone give me an example of where this behaviour might be desired? If not, I'd vote for re-opening this for merge into the core. PS) It turns out my duplication issue was caused by different bug, which I've raised in another issue. |
@foxx Check the history of this discussion - e.g. to run the same test multiple times to track down some flaky behaviour. |
I might have misinterpreted the use case, but I'd argue that if a test suite is producing different results on each run, with no actual change to any of the code, then the tests are broken. That being said, most of the GNU core utils do not have any sort of de-duplication, for example if you run In fact it could be argued that changing the behaviour to be different than the standard of most other utilities, would be the wrong thing to do. In my situation, the problem was caused by a bug with On that basis, I'm changing my vote to -1 |
@nicoddemus FYI, for your usecase: I just wanted to write a |
😆 thanks |
FWIW I'd like to see this implemented in core pytest, so just giving my +1 here. See nicoddemus/pytest-drop-dup-tests#5 for my use-case and issue with the plugin approach (although thanks to niccodemus for making the plugin usable for my case!). |
When passing the same directory twice to py.test, all tests are run twice. The same is true if passing a sub-directory and a parent-directory:
$ python3 -m py.test --collect-only tests/ | grep collected
collecting ... collected 338 items
$ python3 -m py.test --collect-only tests/ tests/ | grep collected
collecting ... collected 676 items
$ python3 -m py.test --collect-only tests/unit/ tests/ | grep collected
collecting ... collected 418 items
platform linux -- Python 3.4.3, pytest-2.8.3, py-1.4.30, pluggy-0.3.1 -- /usr/bin/python3
Rationale: I want to run the unit-test (which are in a certain directory) prior to he other ones. Thus I put the
tests/unit
directory in front, but this gave me duplicate tests.The text was updated successfully, but these errors were encountered: