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.

pytest.skip() does not work with testing.condition

See original GitHub issue

Test code:

import unittest                 
import pytest                   
from chainer.testing import condition                           

class TestAaa(unittest.TestCase):                               

    @condition.retry(32)        
    def test_aaa(self):         
        pytest.skip('aaa')      
        assert False            

Result:

________________________________________________________ TestAaa.test_aaa ________________________________________________________
chainer/testing/condition.py:74: in wrapper
    fail()
chainer/testing/condition.py:51: in fail
    instance.fail(msg)
E   AssertionError: 
E   Fail: 32, Success: 0
E   
E   The first error message:
E   Traceback (most recent call last):
E     File "/data/work/w/repos/chainer/chainer/testing/condition.py", line 60, in <lambda>
E       lambda: f(ins, *args[1:], **kwargs),
E     File "/data/work/w/repos/chainer/tests/chainer_tests/test_aaa.py", line 9, in test_aaa
E       pytest.skip('aaa')
E     File "/home/niboshi/anaconda/anaconda3/lib/python3.6/site-packages/_pytest/outcomes.py", line 72, in skip
E       raise Skipped(msg=msg)
E   Skipped: aaa
==================================================== 1 failed in 0.65 seconds ====================================================

After removing retry:

=================================================== 1 skipped in 0.60 seconds ====================================================

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
kmaehashicommented, Apr 25, 2018

Let’s fix chainer.testing to pass-through unittest.case.SkipTest exception, so that we can use the standard self.skipTest() until the discussion in #4557 has settled.

0reactions
niboshicommented, Sep 26, 2019

It’s better to fix condition and allow pytest.skip(). https://github.com/cupy/cupy/pull/2483#discussion_r327523206

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use skip and xfail to deal with tests that cannot succeed
A skip means that you expect your test to pass only if some conditions are met, otherwise pytest should skip running the test...
Read more >
How do I disable a test using pytest? - Stack Overflow
Another useful thing is to skipif using a function call. You can get the function to return a dictionary containing condition and reason...
Read more >
How to skip a test case based on condition using PyTest?
If you wish to skip something conditionally then you can use skipif instead. Here is an example of marking a test function to...
Read more >
Pytest options - how to skip or run specific tests - qavalidation
Pytest provides an option as skipif to use a condition to skip a test, if the condition evaluates to true, then only test...
Read more >
pytest.mark.skipif not skiping the test if the condition is True
I added a boolean flag variable in the test suit as "test_flag" and assigned a value as False initially. If any dependant test...
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