[PATCH v2] tests: fix assertion rewriting in some tests with pytest-3.0.0+
Thomas De Schampheleire
patrickdepinguin at gmail.com
Tue Sep 13 19:54:11 UTC 2016
On Mon, Sep 12, 2016 at 9:38 PM, Mads Kiilerich <mads at kiilerich.com> wrote:
> On 09/12/2016 09:29 PM, Thomas De Schampheleire wrote:
>>
>>
>>> It seems like also here, the problem is that we do too much in
>>> __init__.py .
>>> Perhaps this initialization (with slight modifications) should be in
>>> kallithea/tests/__init__.py, but TestController and helper functions
>>> should
>>> first move to something like kallithea/tests/base.py .
>>>
>> Perhaps so, but even then with
>> 'register_assert_rewrite('kallithea.tests') from
>> kallithea/tests/__init__.py, the warning would pop up. I haven't tried
>> to add a trailing dot there, to indicate all submodules. Is that valid
>> python syntax?
>
>
>
> I don't know what the function accepts - they could allow more than exactly
> Python. But I guess the register function also can be used to specify
> several paths - perhaps by calling it multiple times?
Yes, we could explicitly specify api_base.py and models/common.py, but
I actually considered that fragile. Having the entire set under
kallithea/tests/ seems more future-proof.
It seems the trailing dot is accepted and does what I hoped it does.
v3 is coming up...
>
> It still seems to me like having it in pytest.ini would be cleaner and solve
> this problem ... if possible. I assume it pytest will rewrite asserts in
> 'python_files = kallithea/tests/**/test_*.py', so the problem could be
> solved by putting the base asserts in files matching that pattern ... or
> adding another pattern that maches the helper file.
I can't seem to make this work, either adding e.g. api_base.py to the
python_files, or renaming api_base.py to test_api_base.py.
In either case, asserts in the api tests are still plain.
More information about the kallithea-general
mailing list