From 0a9b1e45fcf712dbe4ddff9d51d5b870bbc60d7d Mon Sep 17 00:00:00 2001 From: Amrith Kumar Date: Thu, 17 Nov 2016 06:11:39 -0500 Subject: [PATCH] Enable hacking extensions framework This change enables the hacking extensions ability in trove. That includes bumping the version of hacking that we use, and also adding the enable-extensions like in the [flake8] section. I've enabled two of the hacking extensions here. There are some limitations to the hacking rules that I've enabled so I'm also going to enter two bugs that others can fix (if they so desire). Change-Id: I6d8fc4bc03f948b84ad823e5248d78a4caa5c042 Related-Bug: 1642554 Related-Bug: 1642552 --- test-requirements.txt | 2 +- tox.ini | 1 + trove/tests/unittests/common/test_dbmodels.py | 4 ++-- trove/tests/unittests/secgroups/test_security_group.py | 4 ++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/test-requirements.txt b/test-requirements.txt index 865e6fa9a3..87fb7fbed1 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -2,7 +2,7 @@ # of appearance. Changing the order has an impact on the overall integration # process, which may cause wedges in the gate later. # Hacking already pins down pep8, pyflakes and flake8 -hacking<0.11,>=0.10.0 +hacking<0.13,>=0.12.0 # Apache-2.0 bandit>=1.1.0 # Apache-2.0 sphinx!=1.3b1,<1.4,>=1.2.1 # BSD os-api-ref>=1.0.0 # Apache-2.0 diff --git a/tox.ini b/tox.ini index 73e4b114cb..c9332fd58c 100644 --- a/tox.ini +++ b/tox.ini @@ -72,6 +72,7 @@ show-source = True # H301 is ignored on purpose. # The rest of the ignores are TODOs. ignore = F821,H301,H404,H405,H501 +enable-extensions = H203,H106 builtins = _ exclude=.venv,.tox,.git,dist,doc,*egg,tools,etc,build,*.po,*.pot,integration filename=*.py,trove-* diff --git a/trove/tests/unittests/common/test_dbmodels.py b/trove/tests/unittests/common/test_dbmodels.py index 77bfdfebdb..02c46c48fa 100644 --- a/trove/tests/unittests/common/test_dbmodels.py +++ b/trove/tests/unittests/common/test_dbmodels.py @@ -135,7 +135,7 @@ class DatastoreUserTest(trove_testtools.TestCase): def _test_user_basic(self, user): self.assertEqual(self.username, user.name) - self.assertEqual(None, user.password) + self.assertIsNone(user.password) self.assertEqual(self.host_wildcard, user.host) self.assertEqual([], user.databases) @@ -316,7 +316,7 @@ class DatastoreUserTest(trove_testtools.TestCase): def test_validate_dict_defaults(self): user = models.DatastoreUser(self.username) user.verify_dict() - self.assertEqual(None, user.password) + self.assertIsNone(user.password) self.assertEqual(self.host_wildcard, user.host) self.assertEqual([], user.databases) diff --git a/trove/tests/unittests/secgroups/test_security_group.py b/trove/tests/unittests/secgroups/test_security_group.py index 459a303e4c..9e1ef45f6d 100644 --- a/trove/tests/unittests/secgroups/test_security_group.py +++ b/trove/tests/unittests/secgroups/test_security_group.py @@ -164,8 +164,8 @@ class SecurityGroupDeleteTest(trove_testtools.TestCase): sec_mod.SecurityGroupInstanceAssociation.find_by = Mock( return_value=fake_SecGr_Association()) sec_mod.SecurityGroupInstanceAssociation.delete = self.fException - self.assertNotEqual(sec_mod.SecurityGroupInstanceAssociation.find_by( - i_id, deleted=False).get_security_group(), None) + self.assertIsNotNone(sec_mod.SecurityGroupInstanceAssociation.find_by( + i_id, deleted=False).get_security_group()) self.assertTrue(hasattr(sec_mod.SecurityGroupInstanceAssociation. find_by(i_id, deleted=False). get_security_group(), 'delete'))