question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Improve debuggability in event of test failure

See original GitHub issue

pytest 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:closed
  • Created 4 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
blueyedcommented, Nov 19, 2019

-l? Not sure what that does, pretty sure I’m not using it.

Looking at pytest --help can be useful in general… 😃

1reaction
blueyedcommented, Nov 19, 2019

-l shows locals:

_          = 'EXEC sp_mssqlcli_multiple_results'
…
rows       = [['Dawn'], ['Dusk'], ['Midnight']]

With my branch/fork above it shows options used via addopts ini setting or PYTEST_ADDOPTS.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found