New submission from Naitree Zhu <[email protected]>:
When using @skip decorator, `reason` argument is required. But one could easily
overlook that and use it like so:
class SomeTest(TestCase):
@skip
def test_method(self):
# ...
The test actually passes when running with unittest, because it's equivalent to
class SomeTest(TestCase):
def test_method(self):
# ...
test_method = skip(test_method)
This gives the illusion that @skip decorator worked as expected.
I propose we should check the passed in `reason`, and raise error if it looks
like a function/method, therefore prevent this erroneous usage.
In practice, this behavior has misled people using the decorator in the
unintended way. For example: In this chapter of Test-Driven Development with
Python
(http://www.obeythetestinggoat.com/book/chapter_organising_test_files.html),
the author used @skip decorator without `reason` argument.
----------
components: Library (Lib), Tests
messages: 324688
nosy: Naitree Zhu
priority: normal
severity: normal
status: open
title: [unittest] raise error if @skip is used with an argument that looks like
a test method
type: behavior
versions: Python 2.7, Python 3.4, Python 3.5, Python 3.6, Python 3.7, Python 3.8
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue34596>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com