[issue41046] unittest: make skipTest a classmethod

2021-08-29 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Since you always can raise a SkipTest in setUpClass() and setUpModule() and 
changing skipTest() can break existing code (for example the code which calls 
cls.skipTest(None, reason) for some strange reasons), I think that it is not 
worth to change it.

--
nosy: +serhiy.storchaka
status: open -> pending

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41046] unittest: make skipTest a classmethod

2020-07-28 Thread James Corbett


James Corbett  added the comment:

I was careless in my example, it would need to be `cls.skipTest(reason)`. 
However, that really doesn't have anything to do with why it should be a 
`classmethod` instead of an instance method: it's so that you can call 
`skipTest` from `classmethods`, namely `setUpClass` which is called by the 
`unittest` framework. You can currently call `skipTest` from `setUpClass` only 
with something ugly like `cls.skipTest(None, reason)` (i.e. passing `None` for 
the `self` parameter, which works because `self` isn't used).

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41046] unittest: make skipTest a classmethod

2020-06-29 Thread Andrei Daraschenka


Andrei Daraschenka  added the comment:

Hello and thanks for your issue. Can you explain why we need to make method as 
`classmethod` because in your example you don't provide argument for 
`cls.skipTest()`.

--
nosy: +dorosch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41046] unittest: make skipTest a classmethod

2020-06-19 Thread James Corbett


Change by James Corbett :


--
keywords: +patch
pull_requests: +20171
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/20996

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41046] unittest: make skipTest a classmethod

2020-06-19 Thread James Corbett


New submission from James Corbett :

The `unittest.TestCase.skipTest` method, used to skip the current test, is 
currently an instance method. There's nothing to stop it from being a 
`classmethod` or a `staticmethod` though---it doesn't use its reference to 
`self` since it's just a wrapper around the `SkipTest` exception. Making it a 
`classmethod` or `staticmethod` would allow calling the method from 
`setUpClass`. Here's an example:

```
import unittest

class MyTestCase(unittest.TestCase):

@classmethod
def ready_for_tests(cls):
pass

@classmethod
def setUpClass(cls):
if not cls.ready_for_tests():
cls.skipTest()
```

--
components: Library (Lib)
messages: 371914
nosy: jameshcorbett
priority: normal
severity: normal
status: open
title: unittest: make skipTest a classmethod
type: enhancement
versions: Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com