From 95e7a3913dbbb22e0a184e33543613d197074f87 Mon Sep 17 00:00:00 2001 From: Semyon Proshev Date: Mon, 1 Aug 2016 21:19:12 +0300 Subject: [PATCH] Rewrite PyPropertyDefinitionInspection tests as highlighting tests --- .../expected.xml | 49 --------------- .../{src/prop_test.py => test.py} | 22 +++---- .../expected.xml | 61 ------------------- .../{src/prop_test.py => test.py} | 38 ++++++------ .../expected.xml | 9 --- .../{src/prop_test.py => test.py} | 2 +- .../python/PythonInspectionsTest.java | 6 +- 7 files changed, 34 insertions(+), 153 deletions(-) delete mode 100644 python/testData/inspections/PyPropertyDefinitionInspection25/expected.xml rename python/testData/inspections/PyPropertyDefinitionInspection25/{src/prop_test.py => test.py} (56%) delete mode 100644 python/testData/inspections/PyPropertyDefinitionInspection26/expected.xml rename python/testData/inspections/PyPropertyDefinitionInspection26/{src/prop_test.py => test.py} (77%) delete mode 100644 python/testData/inspections/PyPropertyDefinitionInspection33/expected.xml rename python/testData/inspections/PyPropertyDefinitionInspection33/{src/prop_test.py => test.py} (67%) diff --git a/python/testData/inspections/PyPropertyDefinitionInspection25/expected.xml b/python/testData/inspections/PyPropertyDefinitionInspection25/expected.xml deleted file mode 100644 index 38414607ac1f..000000000000 --- a/python/testData/inspections/PyPropertyDefinitionInspection25/expected.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - - prop_test.py - 15 - Getter should return something - - - prop_test.py - 15 - Getter signature should be (self) - - - prop_test.py - 16 - Setter should not return a value - - - prop_test.py - 16 - Setter signature should be (self, value) - - - prop_test.py - 17 - Deleter should not return a value - - - prop_test.py - 18 - The doc parameter should be a string - - - prop_test.py - 21 - Setter should not return a value - - - prop_test.py - 21 - Setter signature should be (self, value) - - - prop_test.py - 48 - Getter should return something - - - diff --git a/python/testData/inspections/PyPropertyDefinitionInspection25/src/prop_test.py b/python/testData/inspections/PyPropertyDefinitionInspection25/test.py similarity index 56% rename from python/testData/inspections/PyPropertyDefinitionInspection25/src/prop_test.py rename to python/testData/inspections/PyPropertyDefinitionInspection25/test.py index 60d6413106d5..52d432315fbb 100644 --- a/python/testData/inspections/PyPropertyDefinitionInspection25/src/prop_test.py +++ b/python/testData/inspections/PyPropertyDefinitionInspection25/test.py @@ -12,13 +12,13 @@ class A(object): pass x1 = property(__getX, __setX, __delX, "doc of x1") - x2 = property(__setX) # should return - x3 = property(__getX, __getX) # should not return - x4 = property(__getX, fdel=__getX) # should not return - x5 = property(__getX, doc=123) # bad doc + x2 = property(__setX) + x3 = property(__getX, __getX) + x4 = property(__getX, fdel=__getX) + x5 = property(__getX, doc=123) x6 = property(lambda self: self._x) - x7 = property(lambda self: self._x, lambda self: self._x) # setter should not return + x7 = property(lambda self: self._x, lambda self: self._x) @property def foo(self): @@ -45,7 +45,7 @@ class A(object): pass @property - def moo(self): # should return + def moo(self): pass @moo.setter @@ -71,9 +71,9 @@ class Ghostbusters(object): gb = Ghostbusters() class B(object): - x = property(gb) # pass - y = property(Ghostbusters()) # pass - z = property(Ghostbusters) # pass + x = property(gb) + y = property(Ghostbusters()) + z = property(Ghostbusters) class Eternal(object): def give(self): @@ -85,5 +85,5 @@ class Eternal(object): while True: x = (yield x) - one = property(give) # should pass - anything = property(giveAndTake) # should pass + one = property(give) + anything = property(giveAndTake) diff --git a/python/testData/inspections/PyPropertyDefinitionInspection26/expected.xml b/python/testData/inspections/PyPropertyDefinitionInspection26/expected.xml deleted file mode 100644 index 5fdadd56a3db..000000000000 --- a/python/testData/inspections/PyPropertyDefinitionInspection26/expected.xml +++ /dev/null @@ -1,61 +0,0 @@ - - - - prop_test.py - 21 - Names of function and decorator don't match; property accessor is not created - - - prop_test.py - 25 - Names of function and decorator don't match; property accessor is not created - - - prop_test.py - 30 - Getter should return something - - - prop_test.py - 34 - Setter should not return a value - - - prop_test.py - 38 - Deleter should not return a value - - - prop_test.py - 222 - light_idea_test_case - - Property definitions - Setter should not return a value - - - prop_test.py - 237 - light_idea_test_case - - Property definitions - Setter should not return a value - - - prop_test.py - 268 - light_idea_test_case - - Property definitions - Setter should not return a value - - - prop_test.py - 284 - light_idea_test_case - - Property definitions - Setter should not return a value - - - diff --git a/python/testData/inspections/PyPropertyDefinitionInspection26/src/prop_test.py b/python/testData/inspections/PyPropertyDefinitionInspection26/test.py similarity index 77% rename from python/testData/inspections/PyPropertyDefinitionInspection26/src/prop_test.py rename to python/testData/inspections/PyPropertyDefinitionInspection26/test.py index 40a6edc922a7..6dd8927c9788 100644 --- a/python/testData/inspections/PyPropertyDefinitionInspection26/src/prop_test.py +++ b/python/testData/inspections/PyPropertyDefinitionInspection26/test.py @@ -18,24 +18,24 @@ class A(object): def boo(self): return self._x - @boo.setter # name mismatch + @boo.setter def boo1(self, x): self._x = x - @boo.deleter # name mismatch + @boo.deleter def boo2(self): pass @property - def moo(self): # should return + def moo(self): pass @moo.setter - def moo(self, x): # shouldn't return + def moo(self, x): return 1 @moo.deleter - def moo(self): # shouldn't return + def moo(self): return self._x @qoo.setter # unknown qoo is reported in ref inspection @@ -83,7 +83,7 @@ class Test(object): return n self._myprop = inner_func(val) - myprop = property(get_myprop, set_myprop) # pass + myprop = property(get_myprop, set_myprop) # all flows have exit point @@ -93,13 +93,13 @@ class Test(object): def get_myprop(self): if a > b: - return self._myprop + return self._myprop elif a < b: raise self._myprop else: yield self._myprop - myprop = property(get_myprop) # pass + myprop = property(get_myprop) # some flows have not exit point @@ -113,7 +113,7 @@ class Test(object): elif a < b: raise self._myprop - myprop = property(get_myprop) # pass + myprop = property(get_myprop) # some flows have not exit point @@ -125,7 +125,7 @@ class Test(object): if a > b: return self._myprop - myprop = property(get_myprop) # pass + myprop = property(get_myprop) # non-empty for @@ -137,7 +137,7 @@ class Test(object): for i in range(5): yield i - myprop = property(get_myprop) # pass + myprop = property(get_myprop) # empty for @@ -163,7 +163,7 @@ class Test(object): yield i i += 1 - myprop = property(get_myprop) # pass + myprop = property(get_myprop) # empty while @@ -190,7 +190,7 @@ class Test(object): yield i i += 1 - myprop = property(get_myprop) # pass + myprop = property(get_myprop) # empty while with two conditions @@ -219,7 +219,7 @@ class Test(object): self._myprop = val return 10 - myprop = property(get_myprop, set_myprop) # shouldn't pass + myprop = property(get_myprop, set_myprop) # setter has exit point @@ -234,7 +234,7 @@ class Test(object): self._myprop = val yield 10 - myprop = property(get_myprop, set_myprop) # shouldn't pass + myprop = property(get_myprop, set_myprop) # setter has raise statement @@ -249,7 +249,7 @@ class Test(object): self._myprop = val raise NotImplementedError() - myprop = property(get_myprop, set_myprop) # pass + myprop = property(get_myprop, set_myprop) # setter has exit point in some flow @@ -265,7 +265,7 @@ class Test(object): if a > b: return 10 - myprop = property(get_myprop, set_myprop) # shouldn't pass + myprop = property(get_myprop, set_myprop) # setter has exit point in some flow @@ -281,7 +281,7 @@ class Test(object): if a > b: yield 10 - myprop = property(get_myprop, set_myprop) # shouldn't pass + myprop = property(get_myprop, set_myprop) # setter has raise statement in some flow @@ -297,4 +297,4 @@ class Test(object): if a > b: raise NotImplementedError() - myprop = property(get_myprop, set_myprop) # pass + myprop = property(get_myprop, set_myprop) diff --git a/python/testData/inspections/PyPropertyDefinitionInspection33/expected.xml b/python/testData/inspections/PyPropertyDefinitionInspection33/expected.xml deleted file mode 100644 index d12754a111d5..000000000000 --- a/python/testData/inspections/PyPropertyDefinitionInspection33/expected.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - prop_test.py - 3 - Getter should return or yield something - - - diff --git a/python/testData/inspections/PyPropertyDefinitionInspection33/src/prop_test.py b/python/testData/inspections/PyPropertyDefinitionInspection33/test.py similarity index 67% rename from python/testData/inspections/PyPropertyDefinitionInspection33/src/prop_test.py rename to python/testData/inspections/PyPropertyDefinitionInspection33/test.py index 516047992b8e..c34fd36671f4 100644 --- a/python/testData/inspections/PyPropertyDefinitionInspection33/src/prop_test.py +++ b/python/testData/inspections/PyPropertyDefinitionInspection33/test.py @@ -1,6 +1,6 @@ class A: @property - def normal_property(self): + def normal_property(self): pass @property diff --git a/python/testSrc/com/jetbrains/python/PythonInspectionsTest.java b/python/testSrc/com/jetbrains/python/PythonInspectionsTest.java index bc70a252c58d..26a1791d4720 100644 --- a/python/testSrc/com/jetbrains/python/PythonInspectionsTest.java +++ b/python/testSrc/com/jetbrains/python/PythonInspectionsTest.java @@ -240,16 +240,16 @@ public class PythonInspectionsTest extends PyTestCase { } public void testPyPropertyDefinitionInspection25() { - doTestWithLanguageLevel(getTestName(false), new PyPropertyDefinitionInspection(), LanguageLevel.PYTHON25); + doHighlightingTest(PyPropertyDefinitionInspection.class, LanguageLevel.PYTHON25); } public void testPyPropertyDefinitionInspection26() { - doTestWithLanguageLevel(getTestName(false), new PyPropertyDefinitionInspection(), LanguageLevel.PYTHON26); + doHighlightingTest(PyPropertyDefinitionInspection.class, LanguageLevel.PYTHON26); } // PY-11426 public void testPyPropertyDefinitionInspection33() { - doTestWithLanguageLevel(getTestName(false), new PyPropertyDefinitionInspection(), LanguageLevel.PYTHON33); + doHighlightingTest(PyPropertyDefinitionInspection.class, LanguageLevel.PYTHON33); } public void testInconsistentIndentation() {