Improve debuggability in event of test failure
See original GitHub issuepytest with code coverage enabled won’t provide useful contextual information provided normally by pytest. This makes debugging failures especially difficult.
As an example: with code coverage enabled I may see the following failure:
try:
list(client.execute_query(create_stored_proc))
row_counts = []
for rows, _, _, _, is_error in client.execute_query(exec_stored_proc):
row_counts.append(len(rows))
> assert row_counts[0] != 2
E assert 2 != 2
tests/test_mssqlcliclient.py:190: AssertionError
But if I run the same test without coverage reports (normal pytest
call) I get a lot of great info for debugging:
try:
list(client.execute_query(create_stored_proc))
row_counts = []
for rows, _, _, _, is_error in client.execute_query(exec_stored_proc):
row_counts.append(len(rows))
> assert row_counts[0] != 2
E assert 2 != 2
_ = 'EXEC sp_mssqlcli_multiple_results'
client = <mssqlcli.mssqlcliclient.MssqlCliClient object at 0x102ff6d90>
create_stored_proc = "CREATE PROC sp_mssqlcli_multiple_results AS BEGIN SELECT 'Morning' as [Name] UNION ALL select 'Evening' SELECT 'Dawn' as [Name] UNION ALL select 'Dusk' UNION ALL select 'Midnight' END"
del_stored_proc = 'DROP PROCEDURE sp_mssqlcli_multiple_results'
exec_stored_proc = 'EXEC sp_mssqlcli_multiple_results'
is_error = False
row_counts = [2, 3]
rows = [['Dawn'], ['Dusk'], ['Midnight']]
tests/test_mssqlcliclient.py:190: AssertionError
Is there any way I can get a stack trace similar to the below example?
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (6 by maintainers)
Top Results From Across the Web
Debugging and Fixing a Failing Test - Telerik
You need to fix those failures! Here's a quick walk through of one easy way to resolve test failures using the visual debugger....
Read more >Fix Your Failing Tests: A Debugging Checklist for React ...
Solutions to the most common React testing issues.
Read more >7 Debugging Techniques to Speed Up Troubleshooting | Toptal
7 Debugging Techniques To Speed Up Troubleshooting in Production. Providing production support to an application is one of the most challenging aspects of ......
Read more >Handling Increased Test Failures and Detecting Longer Test ...
With Foresight in hand, you can spend more time writing tests, and less time debugging failed and long-running tests. Start improving your tests' ......
Read more >How to Improve Your Debugging Skills - freeCodeCamp
Failing to Solve their Problem Again One of the most successful debugging techniques I have found is to try to walk through your...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Looking at
pytest --help
can be useful in general… 😃-l
shows locals:With my branch/fork above it shows options used via addopts ini setting or PYTEST_ADDOPTS.