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.

Show only reason why test failed without traceback

See original GitHub issue

Hello,

My current test is run from a python script looking like this:

from tavern.core import run

success = run("C:\FrameWork_FAIL\\tests\YAMLFiles\\test_fileService.tavern.yaml", pytest_args = ["--tb=short"])

Running like this is really verbose even with pytest_args = [“–tb=line”] . The output looks like

======================================================== test session starts =========================================================
platform win32 -- Python 3.6.5, pytest-4.4.1, py-1.8.0, pluggy-0.11.0
rootdir: C:\FrameWork_FAIL
plugins: pylama-7.6.6, tavern-0.26.3
collected 1 item                                                                                                                      

tests\YAMLFiles\test_fileService.tavern.yaml F                                                                                  [100%]

============================================================== FAILURES ==============================================================
_____________________ C:\FrameWork_FAIL\tests\YAMLFiles\test_fileService.tavern.yaml::Get method on FAS endpoint _____________________
C:\Users\AndreiBaltat\AppData\Local\Programs\Python\Python36-32\lib\site-packages\_pytest\runner.py:226: in from_call
    result = func()
C:\Users\AndreiBaltat\AppData\Local\Programs\Python\Python36-32\lib\site-packages\_pytest\runner.py:198: in <lambda>
    lambda: ihook(item=item, **kwds), when=when, reraise=reraise
C:\Users\AndreiBaltat\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pluggy\hooks.py:289: in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
C:\Users\AndreiBaltat\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pluggy\manager.py:68: in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
C:\Users\AndreiBaltat\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pluggy\manager.py:62: in <lambda>
    firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
C:\Users\AndreiBaltat\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pluggy\callers.py:208: in _multicall
    return outcome.get_result()
C:\Users\AndreiBaltat\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pluggy\callers.py:80: in get_result
    raise ex[1].with_traceback(ex[2])
C:\Users\AndreiBaltat\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pluggy\callers.py:187: in _multicall
    res = hook_impl.function(*args)
C:\Users\AndreiBaltat\AppData\Local\Programs\Python\Python36-32\lib\site-packages\_pytest\runner.py:123: in pytest_runtest_call
    item.runtest()
c:\users\andreibaltat\appdata\local\programs\python\python36-32\lib\site-packages\tavern\testutils\pytesthook\item.py:154: in runtest
    run_test(self.path, self.spec, self.global_cfg)
C:\Users\AndreiBaltat\AppData\Local\Programs\Python\Python36-32\lib\site-packages\tavern\core.py:206: in run_test
    run_stage_with_retries(sessions, stage, tavern_box, test_block_config)
C:\Users\AndreiBaltat\AppData\Local\Programs\Python\Python36-32\lib\site-packages\tavern\core.py:241: in run_stage
    saved = v.verify(response)
c:\users\andreibaltat\appdata\local\programs\python\python36-32\lib\site-packages\tavern\_plugins\rest\response.py:217: in verify
    failures=self.errors,
E   tavern.util.exceptions.TestFailError: Test 'Positive test' failed:
E   - Status code was 301, expected 400
--------------------------------------------------------- Captured log call ----------------------------------------------------------
base.py                     41 ERROR    Status code was 301, expected 400
====================================================== 1 failed in 1.28 seconds ======================================================

Is there any way for me to show only the reason why the test failed? Something like:

--------------------------------------------------------- Captured log call ----------------------------------------------------------
base.py                     41 ERROR    Status code was 301, expected 400

Thank you for the response! 😃

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
YAMLcasecommented, Apr 29, 2020

@chrisinmtown Is there a workaround to get non-verbose-overkill output?

Edit: to answer my own question after trying it myself, it appears the new traceback is default in 1.0:

https://tavern.readthedocs.io/en/latest/debugging.html#new-traceback-option“This output style will become the default in version 1.0.”

0reactions
chrisinmtowncommented, Apr 24, 2020

For people who land here in 2020, version --tavern-beta-new-traceback seems to be supported by Tavern version 0.34.0 but not by version 1.0.0 that was released 5 Apr 2020.

Read more comments on GitHub >

github_iconTop Results From Across the Web

pytest failure with no traceback or showing code
i want to change the behavior of pytest failure. i don't want to see a code or any trace back in the failure...
Read more >
Understanding the Python Traceback
Python prints a traceback when an exception is raised in your code. The traceback output can be a bit overwhelming if you're seeing...
Read more >
Improve test error messages of your abstractions
Being able to see not only the error itself. Now, I'm going to keep things contrived here to make it simple, but stick...
Read more >
unittest — Unit testing framework — Python 3.11.1 ...
An extensive list of Python testing tools including functional testing frameworks ... check that s.split fails when the separator is not a string...
Read more >
traceback-with-variables - PyPI
Debug reasons of exceptions by logging or pretty printing colorful variable ... Python Traceback (Error Message) Printing Variables ... Just stop it.
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