1
+ from distutils .version import LooseVersion
2
+
1
3
import itertools as itt
4
+ import pytest
2
5
3
6
from pytest_cases import parametrize , fixture , param_fixtures , fixture_union
4
7
@@ -9,31 +12,55 @@ def mygen(name):
9
12
yield "%s{%i}" % (name , i )
10
13
11
14
12
- @fixture ()
13
- @parametrize ("y" , [0 , 1 ], ids = ("y{%i}" % i for i in itt .count ()))
14
- @parametrize ("x" , [1 , 2 ], ids = mygen ("x" ))
15
- def my_fixture (x , y ):
16
- return x , y
15
+ if LooseVersion (pytest .__version__ ) < LooseVersion ('3.0.0' ):
16
+ @fixture
17
+ @parametrize ("x" , [1 , 2 ], ids = mygen ("x" ))
18
+ def my_fixture (x ):
19
+ return x
20
+
21
+ a = param_fixtures ("a" , ['aa' , 'ab' ], ids = mygen ("a" ))
22
+
23
+ my_union = fixture_union ("my_union" , [a ], ids = mygen ("myunion" ))
24
+
25
+
26
+ def test_foo (my_fixture , my_union , a ):
27
+ pass
28
+
29
+
30
+ def test_synthesis (module_results_dct ):
31
+ assert list (module_results_dct ) == [
32
+ 'test_foo[x{0}-myunion{0}-a{0}]' ,
33
+ 'test_foo[x{0}-myunion{0}-a{1}]' ,
34
+ 'test_foo[x{1}-myunion{0}-a{0}]' ,
35
+ 'test_foo[x{1}-myunion{0}-a{1}]'
36
+ ]
37
+
38
+ else :
39
+ @fixture
40
+ @parametrize ("y" , [0 , 1 ], ids = ("y{%i}" % i for i in itt .count ()))
41
+ @parametrize ("x" , [1 , 2 ], ids = mygen ("x" ))
42
+ def my_fixture (x , y ):
43
+ return x , y
17
44
18
45
19
- a = param_fixtures ("a" , ['aa' , 'ab' ], ids = mygen ("a" ))
46
+ a = param_fixtures ("a" , ['aa' , 'ab' ], ids = mygen ("a" ))
20
47
21
48
22
- my_union = fixture_union ("my_union" , [a ], ids = mygen ("myunion" ))
49
+ my_union = fixture_union ("my_union" , [a ], ids = mygen ("myunion" ))
23
50
24
51
25
- def test_foo (my_fixture , my_union , a ):
26
- pass
52
+ def test_foo (my_fixture , my_union , a ):
53
+ pass
27
54
28
55
29
- def test_synthesis (module_results_dct ):
30
- assert list (module_results_dct ) == [
31
- 'test_foo[x{0}-y{0}-myunion{0}-a{0}]' ,
32
- 'test_foo[x{0}-y{0}-myunion{0}-a{1}]' ,
33
- 'test_foo[x{0}-y{1}-myunion{0}-a{0}]' ,
34
- 'test_foo[x{0}-y{1}-myunion{0}-a{1}]' ,
35
- 'test_foo[x{1}-y{0}-myunion{0}-a{0}]' ,
36
- 'test_foo[x{1}-y{0}-myunion{0}-a{1}]' ,
37
- 'test_foo[x{1}-y{1}-myunion{0}-a{0}]' ,
38
- 'test_foo[x{1}-y{1}-myunion{0}-a{1}]'
39
- ]
56
+ def test_synthesis (module_results_dct ):
57
+ assert list (module_results_dct ) == [
58
+ 'test_foo[x{0}-y{0}-myunion{0}-a{0}]' ,
59
+ 'test_foo[x{0}-y{0}-myunion{0}-a{1}]' ,
60
+ 'test_foo[x{0}-y{1}-myunion{0}-a{0}]' ,
61
+ 'test_foo[x{0}-y{1}-myunion{0}-a{1}]' ,
62
+ 'test_foo[x{1}-y{0}-myunion{0}-a{0}]' ,
63
+ 'test_foo[x{1}-y{0}-myunion{0}-a{1}]' ,
64
+ 'test_foo[x{1}-y{1}-myunion{0}-a{0}]' ,
65
+ 'test_foo[x{1}-y{1}-myunion{0}-a{1}]'
66
+ ]
0 commit comments