If you want to see the declarative tests, here it is.
https://github.com/construct/construct/blob/master/tests/test_all.py
pozdrawiam,
Arkadiusz Bulski
2016-09-08 2:13 GMT+02:00 Arek Bulski
See for yourself. There is a long list of declarative tests. https://github.com/construct/construct/blob/master/tests/test_all.py
pozdrawiam, Arkadiusz Bulski
2016-09-08 1:28 GMT+02:00 Alexander Belopolsky < alexander.belopolsky@gmail.com>:
On Wed, Sep 7, 2016 at 6:56 PM, Arek Bulski
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)])
On Wed, Sep 7, 2016 at 8:14 PM, Arek Bulski
If you want to see the declarative tests, here it is. https://github.com/construct/construct/blob/master/tests/test_all.py
So, why can't you call random.shuffle(all_tests) if you want to run your tests in random order? If for some reason you prefer to stick shuffled in for i, (func, args, res, exctype) in enumerate(tests): I would say it is a bad idea because it is not clear whether you would want enumerate(shuffled(tests)) or shuffled(enumerate(tests)) and what the difference between the two constructs is.
On Wed, Sep 7, 2016 at 9:12 PM, Alexander Belopolsky < alexander.belopolsky@gmail.com> wrote:
On Wed, Sep 7, 2016 at 8:14 PM, Arek Bulski
wrote: If you want to see the declarative tests, here it is. https://github.com/construct/construct/blob/master/tests/test_all.py
So, why can't you call random.shuffle(all_tests) if you want to run your tests in random order?
It may be instructive for you to see how this functionality is implemented in CPython's own test suit: https://github.com/python/cpython/blob/276f4ef97a434d4279a2d207daa34cafcf099...
participants (2)
-
Alexander Belopolsky
-
Arek Bulski