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

trial does not honor unittest @skipIf decorator on classes #9829

Closed
twisted-trac opened this issue May 13, 2020 · 3 comments
Closed

trial does not honor unittest @skipIf decorator on classes #9829

twisted-trac opened this issue May 13, 2020 · 3 comments

Comments

@twisted-trac
Copy link

rodrigc's avatar @rodrigc reported
Trac ID trac#9829
Type enhancement
Created 2020-05-13 21:26:45Z

The @unittest.skipIf decorator ( https://docs.python.org/3/library/unittest.html#skipping-tests-and-expected-failures ) instructs a test runner such as pytest or unittest to skip a specific test function.
This partially works with trial.

This works with trial, i.e. the test_skipThis() function gets marked as SKIPPED:

class MyTests(TestCase):

       @skipIf(True, "skip reason")
       def test_skipThis(self):

This does not work with trial, i.e. all the tests in the SkipAllTests class are executed instead of skipped.


@skipIf(True, "skip reason")
class SkipAllTests(TestCase):

       def test_skipThisFirst(self):
           print("Should never get here first")

        def test_skipThisSecond(self):
            print("Should never get here second")

It would be good to enhance trial to honor the @skipIf decorator on classes.

In the @skipIf implementation, two attributes are set unittest_skip and unittest_skip_why:

See: skipIf implementation

In the unittest runner, these attributes are checked:

unittest implementation checks attributes

The pytest runner also checks these attributes:

pytest implementation checks attribute

So trial should be enhanced to behave like unittest and pytest.

Searchable metadata
trac-id__9829 9829
type__enhancement enhancement
reporter__rodrigc rodrigc
priority__normal normal
milestone__None None
branch__ 
branch_author__ 
status__closed closed
resolution__fixed fixed
component__trial trial
keywords__None None
time__1589405205483644 1589405205483644
changetime__1590940454705386 1590940454705386
version__None None
owner__Craig_Rodrigues__rodrigc_____ Craig Rodrigues <rodrigc@...>

@twisted-trac
Copy link
Author

rodrigc's avatar @rodrigc commented

#1272

@twisted-trac
Copy link
Author

rodrigc's avatar @rodrigc commented

Approved here: #1272 (review)

@twisted-trac
Copy link
Author

rodrigc's avatar @rodrigc set owner to @rodrigc
@rodrigc set status to closed

In changeset 52e7518

#!CommitTicketReference repository="" revision="52e7518232b5031ae38e1e477786a0afa761df9b"
Merge pull request #1272 from twisted/9829-rodrigc-trial

Allow @unittest.skipIf decorator to specify that a test class should be skipped

Author: rodrigc
Reviewer: adiroiban
Fixes: ticket:9829

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

1 participant