Giter VIP home page Giter VIP logo

Comments (5)

mmetc avatar mmetc commented on September 1, 2024

Having scope=module on the other hand is useful to run a battery of tests against a set of environments defined in the same file. At least it's a better fit for my use case, otherwise I have to run pytest multiple times.

from pytest-docker.

austinkeller avatar austinkeller commented on September 1, 2024

@mmetc in that case, it'd be better to allow the flag to be set to the desired scope directly, so something like

def pytest_addoption(parser):
    parser.addoption(
        "--containers-scope",
        type=str,
        default="function"
        help="The pytest fixture scope for reusing containers between tests. For available scopes and descriptions, see https://docs.pytest.org/en/6.2.x/fixture.html#fixture-scopes",
    )


@pytest.fixture
def containers_scope_fixture(request):
    return request.config.getoption("--containers-scope")


def containers_scope(fixture_name, config):
    return config.getoption("--containers-scope-fixture", "function"):


@pytest.fixture(scope=containers_scope)
# This annotation can apply to all fixtures, instead of the hard-coded "session" scope

from pytest-docker.

shaohme avatar shaohme commented on September 1, 2024

Having scope=module on the other hand is useful to run a battery of tests against a set of environments defined in the same file. At least it's a better fit for my use case, otherwise I have to run pytest multiple times.

That is true, but sometimes I need different compose.yaml configs for different set of tests. If I haven't got different scopes, I need to run pytest for each set of tests needing the same docker-compose yaml.

from pytest-docker.

SRv6d avatar SRv6d commented on September 1, 2024

I would've expected a function scope to be the default, are there any blockers to implementing this?

from pytest-docker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.