diff options
author | Zuul <zuul@review.opendev.org> | 2019-06-14 22:07:58 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2019-06-14 22:07:58 +0000 |
commit | e4ebf2b6b8ec9f6973799c2a40cdf009c2444e9f (patch) | |
tree | dd6255c838498202880fcb2e09f320721002beb7 /nova/tests/unit/test_hacking.py | |
parent | d59835d4eb9495fe1f29499b0145c6124078ab02 (diff) | |
parent | 8899f8b5b5dfc84e8e0481a5587d0285c6835ec5 (diff) | |
download | nova-e4ebf2b6b8ec9f6973799c2a40cdf009c2444e9f.tar.gz |
Merge "Hacking N363: `in (not_a_tuple)`"
Diffstat (limited to 'nova/tests/unit/test_hacking.py')
-rw-r--r-- | nova/tests/unit/test_hacking.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/nova/tests/unit/test_hacking.py b/nova/tests/unit/test_hacking.py index a3a7c91f4e..e1455d7105 100644 --- a/nova/tests/unit/test_hacking.py +++ b/nova/tests/unit/test_hacking.py @@ -889,3 +889,27 @@ class HackingTestCase(test.NoDBTestCase): for filename in (good_filenames + bad_filenames): self._assert_has_no_errors( code, checks.privsep_imports_not_aliased, filename=filename) + + def test_did_you_mean_tuple(self): + code = """ + if foo in (bar): + if foo in ('bar'): + if foo in (path.to.CONST_1234): + if foo in ( + bar): + """ + errors = [(x + 1, 0, 'N363') for x in range(4)] + self._assert_has_errors( + code, checks.did_you_mean_tuple, expected_errors=errors) + code = """ + def in(this_would_be_weird): + # A match in (any) comment doesn't count + if foo in (bar,) + or foo in ('bar',) + or foo in ("bar",) + or foo in (set1 + set2) + or foo in ("string continuations " + "are probably okay") + or foo in (method_call_should_this_work()): + """ + self._assert_has_no_errors(code, checks.did_you_mean_tuple) |