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
This commit is contained in:
parent
3d2362df36
commit
d3fbb097c1
@ -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
|
||||
-------------------
|
||||
|
Loading…
x
Reference in New Issue
Block a user