diff options
author | Dan Smith <dansmith@redhat.com> | 2016-02-25 12:23:12 -0800 |
---|---|---|
committer | Andrew Laski <andrew@lascii.com> | 2016-03-17 15:49:55 -0400 |
commit | f6e4713bf69aa25b40585b5e53dbde7605e0a090 (patch) | |
tree | 0de6f90750a1b8fe49e9dddd0b8336c1ad50cce2 /HACKING.rst | |
parent | 3ad46e3c7888f533745d4ba71fd3d4095d24e242 (diff) | |
download | nova-f6e4713bf69aa25b40585b5e53dbde7605e0a090.tar.gz |
Add a hacking check for test method closures
A recurring pattern when using multiple mocks is to create a closure
decorated with mocks like:
def test_thing(self):
@mock.patch.object(self.compute, 'foo')
@mock.patch.object(self.compute, 'bar')
def _do_test(mock_bar, mock_foo):
# Test things
_do_test()
However it is easy to leave off the _do_test() and have the test pass
because nothing runs. This check looks for that pattern.
Co-Authored-By: Andrew Laski <andrew@lascii.com>
Change-Id: I4c2395a01470acc7c9e5bcf1d3578d00270a2c07
Diffstat (limited to 'HACKING.rst')
-rw-r--r-- | HACKING.rst | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/HACKING.rst b/HACKING.rst index 4fab467827..6ae98dcb31 100644 --- a/HACKING.rst +++ b/HACKING.rst @@ -59,6 +59,7 @@ Nova Specific Commandments - [N346] Python 3: do not use dict.itervalues. - [N347] Provide enough help text for config options - [N348] Deprecated library function os.popen() +- [N349] Check for closures in tests which are not used Creating Unit Tests ------------------- |