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

raising unittest.SkipTest in setUpClass creates an error #252

Closed
jayvdb opened this issue Sep 8, 2015 · 1 comment
Closed

raising unittest.SkipTest in setUpClass creates an error #252

jayvdb opened this issue Sep 8, 2015 · 1 comment

Comments

@jayvdb
Copy link

jayvdb commented Sep 8, 2015

Within setUp and test methods raise unittest.SkipTest works well.
When a setUpClass has a raise unittest.SkipTest, the following error occurs instead of a skip:

======================================================================
ERROR: _ErrorHolder
----------------------------------------------------------------------
Traceback (most recent call last):
  File ".../tests/aspects.py", line 597, in setUpClass
    super(RequireUserMixin, cls).setUpClass()
  File ".../tests/aspects.py", line 562, in setUpClass
    % (cls.__name__, env_var))
SkipTest: 'TestSiteSysopWrite' write tests disabled. Set PYWIKIBOT2_TEST_WRITE=1 to enable.

https://github.com/wikimedia/pywikibot-core/blob/09dce8fe3b3041eccdc8dc8ede9857cda42a6d7c/tests/aspects.py#L559

@sirosen
Copy link
Collaborator

sirosen commented Feb 14, 2021

I suspected that with recent refactors this might have been resolved.
I just tried to reproduce on the latest version, and this worked just fine:

import unittest


class ExampleTest(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        raise unittest.SkipTest("foo")

    def test_some_stuff(self):
        assert True

However, the above example works correctly on all releases I tested going back to 0.5.0 , so perhaps the above doesn't properly capture the bug?

I'm going to close as a CNR, but I will very happily revisit this if someone can give a failing example for me to test against.

@sirosen sirosen closed this as completed Feb 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants