Excessive tracebacks
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 42/100
Hướng nghiên cứu
Tái hiện lỗi bằng example.feature và test_example.py, sau đó kiểm tra các frame pytest-bdd được hiển thị từ scenario.py và steps.py. So sánh traceback với hành vi --tb=short của pytest; hoàn tất khi các lỗi trong user step vẫn giữ lại frame hữu ích của ứng dụng đồng thời loại bỏ các frame không cần thiết của framework.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
I'm struggling to get tracebacks in pytest-bdd tests down to a manageable size. --tb=short doesn't do too much. It seems to be worst on given steps.
Even on a simple failure within my given step, there are 12 lines of traceback, 3 of pytest-bdd internals and 9 of pytest internals. Is there something pytest-bdd can do to suppress these from the output?
example.feature
Scenario: Checking tracebacks
Given a scenario
When it fails
Then there should be a readable traceback
test_example.py
from pytest_bdd import scenario, given, when, then, parsers
@scenario('example.feature', 'Checking tracebacks')
def test_traceback():
pass
@given(parsers.parse('a {noun:w}'))
def given(noun):
assert noun == 'banana'
@when('it fails')
def when():
pass
@then(parsers.parse('there should be a {adjective:w} traceback'))
def then(adjective):
pass
Output
(bdd-examples-project) bjl@BJL-LAP:/mnt/c/Users/bjl/wsl/bdd-examples-project/tests/features$ pytest -k 'test_traceback -traceback2' --tb=short
============================================================================================================ test session starts ============================================================================================================
platform linux -- Python 3.6.7, pytest-4.4.1, py-1.8.0, pluggy-0.9.0
rootdir: /mnt/c/Users/bjl/wsl/bdd-examples-project/tests, inifile: pytest.ini
plugins: bdd-3.1.0
collected 26 items / 25 deselected / 1 selected
steps/test_example.py F [100%]
================================================================================================================= FAILURES ==================================================================================================================
______________________________________________________________________________________________________________ test_traceback _______________________________________________________________________________________________________________
steps/test_example.py:32: in test_traceback
def test_traceback():
/home/bjl/.local/share/virtualenvs/bdd-examples-project-dSboamh_/lib/python3.6/site-packages/pytest_bdd/scenario.py:195: in _execute_scenario
_execute_step_function(request, scenario, step, step_func)
/home/bjl/.local/share/virtualenvs/bdd-examples-project-dSboamh_/lib/python3.6/site-packages/pytest_bdd/scenario.py:136: in _execute_step_function
step_func(**kwargs)
/home/bjl/.local/share/virtualenvs/bdd-examples-project-dSboamh_/lib/python3.6/site-packages/pytest_bdd/steps.py:164: in step_func
result = request.getfixturevalue(func.__name__)
/home/bjl/.local/share/virtualenvs/bdd-examples-project-dSboamh_/lib/python3.6/site-packages/_pytest/fixtures.py:478: in getfixturevalue
return self._get_active_fixturedef(argname).cached_result[0]
/home/bjl/.local/share/virtualenvs/bdd-examples-project-dSboamh_/lib/python3.6/site-packages/_pytest/fixtures.py:501: in _get_active_fixturedef
self._compute_fixture_value(fixturedef)
/home/bjl/.local/share/virtualenvs/bdd-examples-project-dSboamh_/lib/python3.6/site-packages/_pytest/fixtures.py:586: in _compute_fixture_value
fixturedef.execute(request=subrequest)
/home/bjl/.local/share/virtualenvs/bdd-examples-project-dSboamh_/lib/python3.6/site-packages/_pytest/fixtures.py:895: in execute
return hook.pytest_fixture_setup(fixturedef=self, request=request)
/home/bjl/.local/share/virtualenvs/bdd-examples-project-dSboamh_/lib/python3.6/site-packages/pluggy/hooks.py:289: in __call__
return self._hookexec(self, self.get_hookimpls(), kwargs)
/home/bjl/.local/share/virtualenvs/bdd-examples-project-dSboamh_/lib/python3.6/site-packages/pluggy/manager.py:68: in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
/home/bjl/.local/share/virtualenvs/bdd-examples-project-dSboamh_/lib/python3.6/site-packages/pluggy/manager.py:62: in <lambda>
firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
/home/bjl/.local/share/virtualenvs/bdd-examples-project-dSboamh_/lib/python3.6/site-packages/_pytest/fixtures.py:937: in pytest_fixture_setup
result = call_fixture_func(fixturefunc, request, kwargs)
/home/bjl/.local/share/virtualenvs/bdd-examples-project-dSboamh_/lib/python3.6/site-packages/_pytest/fixtures.py:794: in call_fixture_func
res = fixturefunc(**kwargs)
steps/test_example.py:38: in given
assert noun == 'banana'
E AssertionError: assert 'scenario' == 'banana'
E - scenario
E + banana
(The long paths to pipenv's virtualenv are also certainly not helping...)
- Ngôn ngữ chính
- Python
- Star
- 1.5k
- Fork
- 251
- Merge trung bình
- 43 phút
- Pull request đã merge (30 ngày)
- 2
Chuẩn bị môi trường
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của pytest-dev/pytest-bdd
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 45/100
pytest-dev/pytest-bdd#805 ·
-
YAML support removed in v8Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 30/100
pytest-dev/pytest-bdd#785 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 38/100
pytest-dev/pytest-bdd#784 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
pytest-dev/pytest-bdd#782 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
pytest-dev/pytest-bdd#780 · 3 reaction ·
Tất cả issue của pytest-dev/pytest-bdd
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
spec-kitty/spec-kitty#5319 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
backend::vllm diffusion multimodal
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
openai/openai-agents-python#5229 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Maintainer thường phản hồi trong vòng 1 ngày