Skip to content

Commit 4c095e5

Browse files
author
Sylvain MARIE
committed
Fixed transform_marks_into_decorators for python 2 + pytest 2
1 parent 4598820 commit 4c095e5

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

pytest_cases/common.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -200,22 +200,26 @@ def transform_marks_into_decorators(marks):
200200
try:
201201
for m in marks:
202202
md = pytest.mark.MarkDecorator()
203-
if isinstance(m, type(md)):
204-
# already a decorator, we can use it
205-
marks_mod.append(m)
206-
else:
207-
if LooseVersion(pytest.__version__) >= LooseVersion('3.0.0'):
208-
md.mark = m
203+
204+
if LooseVersion(pytest.__version__) >= LooseVersion('3.0.0'):
205+
if isinstance(m, type(md)):
206+
# already a decorator, we can use it
207+
marks_mod.append(m)
209208
else:
210-
md.name = m.name
211-
# md.markname = m.name
212-
md.args = m.args
213-
md.kwargs = m.kwargs
209+
md.mark = m
210+
marks_mod.append(md)
211+
else:
212+
# always recreate one, type comparison does not work (all generic stuff)
213+
md.name = m.name
214+
# md.markname = m.name
215+
md.args = m.args
216+
md.kwargs = m.kwargs
214217

215218
# markinfodecorator = getattr(pytest.mark, markinfo.name)
216219
# markinfodecorator(*markinfo.args)
217220

218221
marks_mod.append(md)
222+
219223
except Exception as e:
220224
warn("Caught exception while trying to mark case: [%s] %s" % (type(e), e))
221225
return marks_mod

0 commit comments

Comments
 (0)