[New-bugs-announce] [issue36569] @staticmethod seems to work with setUpClass, but docs say it shouldn't

Peter de Blanc report at bugs.python.org
Tue Apr 9 01:40:35 EDT 2019


New submission from Peter de Blanc <peter at standard.ai>:

According to unittest docs: https://docs.python.org/3.7/library/unittest.html#module-unittest

`setUpClass is called with the class as the only argument and must be decorated as a classmethod()`

and:

`tearDownClass is called with the class as the only argument and must be decorated as a classmethod()`

However, I was able to create a passing test case where `setUpClass` and `tearDownClass` are decorated with `@staticmethod` instead of `@classmethod`:

I tested this with Python versions 3.6.4 and 3.7.1.

Please update the documentation to indicate that `@staticmethod` is allowed here, or else indicate why it's bad.

----------
components: Library (Lib)
files: test_bar.py
messages: 339700
nosy: Peter de Blanc, ezio.melotti, michael.foord, rbcollins
priority: normal
severity: normal
status: open
title: @staticmethod seems to work with setUpClass, but docs say it shouldn't
type: behavior
versions: Python 3.6, Python 3.7
Added file: https://bugs.python.org/file48251/test_bar.py

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue36569>
_______________________________________


More information about the New-bugs-announce mailing list