Pytest: меньше выходных данных в конце?

Я выполняю pytest через PyCharm.

Нижняя часть вывода выглядит так:

=================================== FAILURES ===================================
__________________ test_get_landing_page_breadcrumb_for_foos ___________________

    @pytest.mark.django_db
    def test_get_landing_page_breadcrumb_for_foos():
        location = Location.objects.create(canonical_name='test-location', name='Test Location', search_volume=1000)
        term = Term.objects.create(canonical_name='test-term', name='Test Term', search_volume=1500)
>       assert 0, get_landing_page_breadcrumb_for_foos(location.canonical_name,
                                             term.canonical_name, PortalFactory.build())
E       AssertionError: [{'@context': 'http://schema.org', '@type': 'BreadcrumbList', 'itemListElement': [{'@type': 'ListItem', 'item': 'https.../test-location/', 'name': 'test-location', 'position': 2}, {'@type': 'ListItem', 'name': 'test-term', 'position': 3}]}]
E       assert 0

test_search_pages.py:12: AssertionError
---------------------------- Captured stdout setup -----------------------------
Operations to perform:
  Synchronize unmigrated apps: admin_ordering, company_search, compressor, corsheaders, debug_toolbar, django_countries, django_extensions, ...
  Apply all migrations: admin, auth, cms, contenttypes, ....
Synchronizing apps without migrations:
  Creating tables...
    Running deferred SQL...
Running migrations:
  No migrations to apply.
Cache table 'file_resubmit_cache' already exists.
---------------------------- Captured stderr setup -----------------------------
Using existing test database for alias 'default' ('test_foofirm')...
=========================== short test summary info ============================
FAILED test_search_pages.py::test_get_landing_page_breadcrumb_for_foos - Asse...
============================== 1 failed in 4.42s ===============================

Process finished with exit code 1


Assertion failed

Assertion failed

Я хотел бы уменьшить вывод в конце, так как я использую прокрутку до конца, чтобы увидеть важные строки.

Я хотел бы, чтобы конец вывода выглядел так:

=================================== FAILURES ===================================
__________________ test_get_landing_page_breadcrumb_for_foos ___________________

    @pytest.mark.django_db
    def test_get_landing_page_breadcrumb_for_foos():
        location = Location.objects.create(canonical_name='test-location', name='Test Location', search_volume=1000)
        term = Term.objects.create(canonical_name='test-term', name='Test Term', search_volume=1500)
>       assert 0, get_landing_page_breadcrumb_for_foos(location.canonical_name,
                                             term.canonical_name, PortalFactory.build())
E       AssertionError: [{'@context': 'http://schema.org', '@type': 'BreadcrumbList', 'itemListElement': [{'@type': 'ListItem', 'item': 'https.../test-location/', 'name': 'test-location', 'position': 2}, {'@type': 'ListItem', 'name': 'test-term', 'position': 3}]}]
E       assert 0

test_search_pages.py:12: AssertionError

Иногда Captured stdout важен. Но я не хочу быть на дне. Есть ли способ переместить Captured stdout выше FAILURES?

---------------------------- Captured stdout setup -----------------------------
Operations to perform:
  Synchronize unmigrated apps: admin_ordering, company_search, compressor, corsheaders, debug_toolbar, django_countries, django_extensions, ...
  Apply all migrations: admin, auth, cms, contenttypes, ....
Synchronizing apps without migrations:
  Creating tables...
    Running deferred SQL...
Running migrations:
  No migrations to apply.
Cache table 'file_resubmit_cache' already exists.
---------------------------- Captured stderr setup -----------------------------
Using existing test database for alias 'default' ('test_foofirm')...
=========================== short test summary info ============================
FAILED test_search_pages.py::test_get_landing_page_breadcrumb_for_foos - Asse...
============================== 1 failed in 4.42s ===============================

Process finished with exit code 1


Assertion failed

Assertion failed

person guettli    schedule 20.01.2021    source источник


Ответы (1)


Похоже, вы хотите узнать больше о подробная команда в Pytest

Если вы хотите, чтобы ваш вывод был менее подробным, попробуйте pytest -q или pytest --quiet

person Gaëtan GR    schedule 20.01.2021
comment
Извините, я снова подумал об этом. Я хотел бы видеть Captured stdout, но выше FAILURES. - person guettli; 20.01.2021
comment
Вы пробовали этот ответ? stackoverflow.com/a/29804869/15023296 @guettli - person Gaëtan GR; 20.01.2021
comment
Спасибо за эту ссылку. Какой крючок для отчетности может справиться с этой задачей? docs.pytest.org/en/stable/ - person guettli; 20.01.2021