python - Pytest:最后输出更少?
问题描述
我通过 PyCharm 执行 pytest。
输出的底部如下所示:
=================================== 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 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
解决方案
看起来您想了解更多有关Pytest 中的详细命令的信息
如果您希望输出不那么冗长,请尝试pytest -q
或pytest --quiet
推荐阅读
- java - 应用 xss 跨站点脚本来编码 jsp/servlet 应用程序的有效方法
- php - 为什么资源没有在 Laravel 中执行
- html - intro.js 中是否有任何选项可以使突出显示的文本或图像清晰
- r - 如何计算多列中唯一分类值的频率并按年龄分组
- wpf - 如何生成 Windows 证书,以便我的 msi 不会向用户显示警告
- java - 启动画面完成后应用程序不断崩溃
- excel - 根据下拉选择更新列
- c# - 在 ASPX 和 ASP.Net 条件下,无需更改文件夹即可重写 URL
- ios - 如何在应用启动时播放动画以及如何在 GitHub 上使用 SwiftyGif?
- python - 需要从列表列表中选择对应的最大值