comparison conftest.py @ 8215:928bc1d8b279 default-i18n

Merge from default
author Mads Kiilerich <mads@kiilerich.com>
date Thu, 06 Feb 2020 01:19:23 +0100
parents 9948ed9916c4
children
comparison
equal deleted inserted replaced
8214:460e7d2d1b38 8215:928bc1d8b279
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')