[PATCH] tests: hide database setup queries with pytest

Mads Kiilerich mads at kiilerich.com
Mon Jul 13 13:52:08 EDT 2015


On 07/11/2015 09:06 PM, Thomas De Schampheleire wrote:
> # HG changeset patch
> # User Thomas De Schampheleire <thomas.de.schampheleire at gmail.com>
> # Date 1435831639 -7200
> #      Thu Jul 02 12:07:19 2015 +0200
> # Node ID a71b7c1c0efa80456ed9e85dcbba9990eaec154f
> # Parent  53d68f201e4602d3f2ccfcd27107d2ebea2deea2
> tests: hide database setup queries with pytest
>
> Unlike nosetest, pytest would show the database setup queries at the
> beginning of the test run, which don't bring added value.

What is the root cause of this? What is nosetest doing that pytest 
isn't? Are we solving the problem correctly or adding a hack that might 
bite us later?

Would it perhaps be better to change the log level inside test.ini?

> Hide them by disabling logging during this time.
>
> Note that this does not provide an easy method of enabling the logging on
> demand (what could be done with the -s switch in nosetest).
>
> diff --git a/kallithea/tests/conftest.py b/kallithea/tests/conftest.py
> --- a/kallithea/tests/conftest.py
> +++ b/kallithea/tests/conftest.py
> @@ -5,9 +5,12 @@ import pkg_resources
>   from paste.deploy import loadapp
>   import pylons.test
>   from pylons.i18n.translation import _get_translator
> -
> +import logging
>   
>   def pytest_configure():
> +
> +    logging.disable(logging.CRITICAL)

It seems like this is a noop ... except giving improved logging for a while?

> +
>       path = os.getcwd()
>       sys.path.insert(0, path)
>       pkg_resources.working_set.add_entry(path)
> @@ -26,4 +29,6 @@ def pytest_configure():
>       translator = _get_translator(pylons.config.get('lang'))
>       pylons.translator._push_object(translator)
>   
> +    logging.disable(logging.NOTSET)

This is what actually disable the logging? But it will remain disabled 
for all tests? I guess that will make it harder to debug test failures?

/Mads



More information about the kallithea-general mailing list