Mercurial > kallithea
comparison conftest.py @ 8368:e5ccabbc3cd7 stable
release: merge default to stable for 0.6.0
author | Thomas De Schampheleire <thomas.de_schampheleire@nokia.com> |
---|---|
date | Sat, 02 May 2020 21:20:43 +0200 |
parents | 9948ed9916c4 |
children |
comparison
equal
deleted
inserted
replaced
8320:b1b1f69b1f28 | 8368:e5ccabbc3cd7 |
---|---|
1 import os | 1 import os |
2 | 2 |
3 import mock | 3 import mock |
4 import pytest | 4 import pytest |
5 import tg | |
5 | 6 |
6 | 7 |
7 here = os.path.dirname(__file__) | 8 here = os.path.dirname(__file__) |
9 | |
10 # HACK: | |
11 def pytest_configure(): | |
12 # Register global dummy tg.context to avoid "TypeError: No object (name: context) has been registered for this thread" | |
13 tg.request_local.context._push_object(tg.util.bunch.Bunch()) | |
14 # could be removed again after use with | |
15 # tg.request_local.context._pop_object ... but we keep it around forever as | |
16 # a reasonable sentinel | |
8 | 17 |
9 def pytest_ignore_collect(path): | 18 def pytest_ignore_collect(path): |
10 # ignore all files outside the 'kallithea' directory | 19 # ignore all files outside the 'kallithea' directory |
11 if not str(path).startswith(os.path.join(here, 'kallithea')): | 20 if not str(path).startswith(os.path.join(here, 'kallithea')): |
12 return True | 21 return True |
34 >>> getfixture('doctest_mock_ugettext') | 43 >>> getfixture('doctest_mock_ugettext') |
35 """ | 44 """ |
36 m = __import__(request.module.__name__, globals(), locals(), [None], 0) | 45 m = __import__(request.module.__name__, globals(), locals(), [None], 0) |
37 with mock.patch.object(m, '_', lambda s: s): | 46 with mock.patch.object(m, '_', lambda s: s): |
38 yield | 47 yield |
48 | |
49 if getattr(pytest, 'register_assert_rewrite', None): | |
50 # make sure that all asserts under kallithea/tests benefit from advanced | |
51 # assert reporting with pytest-3.0.0+, including api/api_base.py, | |
52 # models/common.py etc. | |
53 # See also: https://docs.pytest.org/en/latest/assert.html#advanced-assertion-introspection | |
54 pytest.register_assert_rewrite('kallithea.tests') |