Skip to content

Commit

Permalink
fix tests for py3.4-3.5
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-mixas committed Feb 6, 2020
1 parent 648cc57 commit 6d13901
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions tests/common.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import contextlib
import os
import pytest


def do_test_function(test, func):
with test['raises']:
assert test.get('result', None) == func(test)
if 'raises' in test:
with test['raises']:
func(test)
else:
assert test['result'] == func(test)


def iterate_test_suite(tests_map, results_mod, func):
Expand All @@ -26,12 +28,10 @@ def iterate_test_suite(tests_map, results_mod, func):
except KeyError:
test['raises'] = pytest.raises(results_map[name]['raises'])

marks = []
if 'raises' not in test:
test['raises'] = pytest_param_does_not_raise()
if 'result' not in test:
test['result'] = None
marks.append(pytest.mark.xfail)
if 'result' in test or 'raises' in test:
marks = []
else:
marks = [pytest.mark.xfail]

yield pytest.param(test, func, id=name, marks=marks)

Expand Down Expand Up @@ -78,8 +78,3 @@ def save_test_suite(filename, results):
print('========== ' + name + ' ==========')
print(RESULTS[name].get('result', None), end='')
""")


@contextlib.contextmanager
def pytest_param_does_not_raise():
yield

0 comments on commit 6d13901

Please sign in to comment.