Skip to content

API for options to specific arbitrary variables #3

Description

@t2y

(Original issue 3 created by sonoflilit on 2013-11-26T18:14:31.291515+00:00)

I'm beginning to think that options being always global (you can't get one number between 1 and 4 and another between 0 and 1000, you can only do randomize(int, int, min_num=0, max_num=1000)) is a bad thing, especially when we introduce container generators.

I'm not sure I have a good API for this. The best I can come up with is this:

#!python

@pytest.mark.randomize(a=int, b=pytest.options(int, min_num=100))
def test_ab():
    assert b >= 100

another idea would be Django style:

#!python

@pytest.mark.randomize(a=int, b=int, b__min_num=100)
def test_ab():
    assert b >= 100

but it doesn't nest well and is generally horrible.

Another one:

#!python

@pytest.mark.randomize(dict(b=int, min_num=100), a=int)
def test_ab():
    assert b >= 100
# which is clearer?
@pytest.mark.randomize({"b": int, min_num=100}, a=int)
def test_ab():
    assert b >= 100

which is shorter but much less intuitive.

Activity

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

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions