Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SkipTest raised inside setupClass treated as error #373

Open
Link512 opened this issue Nov 16, 2017 · 6 comments
Open

SkipTest raised inside setupClass treated as error #373

Link512 opened this issue Nov 16, 2017 · 6 comments
Labels

Comments

@Link512
Copy link

Link512 commented Nov 16, 2017

virtualenv python version: 3.6.2
nose2 version: 0.7.2
unittest2 version: 1.1.0

snippet:

import unittest2

class Failing(unittest2.TestCase):

    @classmethod
    def setUpClass(cls):

        raise unittest2.SkipTest

    def testWillBeIgnored(self):

        self.assertTrue(1)

Expected behaviour: Test case is skipped
Actual behaviour: SkipTest is treated like actual error. See below:

nose2
E
======================================================================
ERROR: _ErrorHolder
----------------------------------------------------------------------
Traceback (most recent call last):
  File "[...]/test_nose/test_failure.py", line 8, in setUpClass
    raise unittest2.SkipTest
unittest2.case.SkipTest

----------------------------------------------------------------------
Ran 0 tests in 0.000s
@katrinabrock
Copy link
Collaborator

Thanks for reporting. I assume this worked fine under 0.6.5? Maybe pin there for now.

This functionality should get tested here:


(but with unittest not unittest2)

@Link512
Copy link
Author

Link512 commented Nov 17, 2017

Yes, with 0.6.5 it works fine.

@katrinabrock
Copy link
Collaborator

Able to reproduce on python version 2.7

@katrinabrock
Copy link
Collaborator

Unsurprisingly, this is where the bug was introduced:
19822c9

@katrinabrock
Copy link
Collaborator

katrinabrock commented Nov 18, 2017

I have more information. In 0.6.5, this type of construct did not properly skip the test if SkipTest from unittest was used. Running this snippet with different versions of nose2 demonstrates this behavior

import unittest
import unittest2


class SkipUnitTest(unittest.TestCase):

    @classmethod
    def setUpClass(cls):

        raise unittest.SkipTest('UnitTest, skipped in 0.7.X')

    def testWillBeIgnored(self):

        self.assertTrue(1)


class SkipUnitTest2(unittest2.TestCase):

    @classmethod
    def setUpClass(cls):

        raise unittest2.SkipTest('UnitTest2, skipped in 0.6.5')

    def testWillBeIgnored(self):

        self.assertTrue(1)

Python 2.7.13

Switching between unittest and unittest2 here

https://github.com/nose-devs/nose2/blob/master/nose2/loader.py#L30

toggles that behavior.

Haven't figured out why or best way to support both unittest.SkipTest and unittest2.SkipTest

@ptthiem
Copy link
Collaborator

ptthiem commented Nov 19, 2017

Ok my joke was wrong... Yeah. It looks like and interesting problem :(.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants