diff options
| author | Laura Médioni <laura.medioni@logilab.fr> | 2015-10-15 17:02:52 +0200 |
|---|---|---|
| committer | Laura Médioni <laura.medioni@logilab.fr> | 2015-10-15 17:02:52 +0200 |
| commit | c2ce68547ea37c4421b8d5c9a6151ee23269a6c5 (patch) | |
| tree | 267e2de27a933bf993c86902ad5ea84dbd00803c /pylint/test/unittest_checker_base.py | |
| parent | 1fd9d5a24428e3112cdf3cefdf4baba2e1c23fd0 (diff) | |
| download | pylint-git-c2ce68547ea37c4421b8d5c9a6151ee23269a6c5.tar.gz | |
add a new rule looking for yoda conditions
Diffstat (limited to 'pylint/test/unittest_checker_base.py')
| -rw-r--r-- | pylint/test/unittest_checker_base.py | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/pylint/test/unittest_checker_base.py b/pylint/test/unittest_checker_base.py index c68f3795b..ec3ae2be8 100644 --- a/pylint/test/unittest_checker_base.py +++ b/pylint/test/unittest_checker_base.py @@ -249,7 +249,7 @@ class MultiNamingStyleTest(CheckerTestCase): class ComparisonTest(CheckerTestCase): CHECKER_CLASS = base.ComparisonChecker - def test_singleton_comparison(self): + def test_comparison(self): node = test_utils.extract_node("foo == True") message = Message('singleton-comparison', node=node, @@ -272,24 +272,33 @@ class ComparisonTest(CheckerTestCase): self.checker.visit_compare(node) node = test_utils.extract_node("True == foo") - message = Message('singleton-comparison', - node=node, - args=(True, "just 'expr' or 'expr is True'")) - with self.assertAddsMessages(message): + messages = (Message('misplaced-comparison-constant', + node=node, + args=('foo == True',)), + Message('singleton-comparison', + node=node, + args=(True, "just 'expr' or 'expr is True'"))) + with self.assertAddsMessages(*messages): self.checker.visit_compare(node) node = test_utils.extract_node("False == foo") - message = Message('singleton-comparison', - node=node, - args=(False, "'not expr' or 'expr is False'")) - with self.assertAddsMessages(message): + messages = (Message('misplaced-comparison-constant', + node=node, + args=('foo == False',)), + Message('singleton-comparison', + node=node, + args=(False, "'not expr' or 'expr is False'"))) + with self.assertAddsMessages(*messages): self.checker.visit_compare(node) node = test_utils.extract_node("None == foo") - message = Message('singleton-comparison', - node=node, - args=(None, "'expr is None'")) - with self.assertAddsMessages(message): + messages = (Message('misplaced-comparison-constant', + node=node, + args=('foo == None',)), + Message('singleton-comparison', + node=node, + args=(None, "'expr is None'"))) + with self.assertAddsMessages(*messages): self.checker.visit_compare(node) |
