Skip to content

Multiplying tests should happen after -k #15

Description

@blueyed

When used with -k to select only some specific tests, pytest still collects all tests, multiplied by the number passed to --count.

Therefore pytest --count=120 -x -k test_foo will collect the number of total tests times 120, which results in a lot of processing and memory usage.

I can imagine that pytest-repeat could be improved in this regard to only multiply the collected tests after -k was applied.

The workaround here is to specify the file containing the test, but that still multiplies the tests contained in this file.

platform linux -- Python 3.6.1, pytest-3.0.7, py-1.4.33, pluggy-0.4.0
cachedir: .cache
Django settings: velodrome.settings (from environment variable)
plugins: testmon-0.9.4, repeat-0.4.1, profiling-1.2.6, pdb-0.2.0, mock-1.6.0, django-3.1.2, catchlog-1.2.2, asyncio-0.5.0, pylama-7.3.3

Activity

RonnyPfannschmidt commented on Apr 24, 2017

@RonnyPfannschmidt
Member

@blueyed that is currently structurally impossible as of now since the multiplication uses a hidden autouse fixture as its about the only sane way to do it atm

blueyed commented on Oct 27, 2019

@blueyed
ContributorAuthor

@RonnyPfannschmidt
Isn't it possible to create new items in pytest_collection_modifyitems instead, based on copying an existing one?

RonnyPfannschmidt commented on Oct 27, 2019

@RonnyPfannschmidt
Member

no

blueyed commented on Oct 27, 2019

@blueyed
ContributorAuthor

Well, it's not easily possible, but should be probably, shouldn't it?

As for now / anyway, see pytest-dev/pytest#6078.

blueyed commented on Oct 27, 2019

@blueyed
ContributorAuthor

@RonnyPfannschmidt
btw: the autouse fixture is removed in #40.

tylovescodes commented on Apr 15, 2020

@tylovescodes

What's the status on this issue? Is this being worked on?

host452b commented on Jan 6, 2025

@host452b

@okken would you help to review MR88 for this issue ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions