[Python-ideas] Shuffled
Alexander Belopolsky
alexander.belopolsky at gmail.com
Wed Sep 7 19:28:57 EDT 2016
On Wed, Sep 7, 2016 at 6:56 PM, Arek Bulski <arek.bulski at gmail.com> wrote:
> In the project I maintain (construct) there are declarative testcases that
> look like a long list of (func, args, excepted output, error type) tuples.
> There is no way for me to call shuffle in there.
Can you explain why? Something like this can be easily done with pytest:
In [1]: def foo(x):
...: return x + 1
...:
In [2]: import pytest
In [3]: @pytest.mark.parametrize('x, y', [
...: (100, 101),
...: (200, 201),
...: (300, 301),])
...: def test_foo(x, y):
...: assert foo(x) == y
...:
In [4]: test_foo.parametrize.args
Out[4]: ('x, y', [(100, 101), (200, 201), (300, 301)])
In [5]: import random
In [6]: random.shuffle(test_foo.parametrize.args[1])
In [7]: test_foo.parametrize.args
Out[7]: ('x, y', [(200, 201), (100, 101), (300, 301)])
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160907/a8534a0b/attachment.html>
More information about the Python-ideas
mailing list