diff --git a/python/testData/inspections/PyTupleAssignmentBalanceInspection2/test.py b/python/testData/inspections/PyTupleAssignmentBalanceInspection2/test.py deleted file mode 100644 index 1f7095aa31d3..000000000000 --- a/python/testData/inspections/PyTupleAssignmentBalanceInspection2/test.py +++ /dev/null @@ -1,24 +0,0 @@ -a, b, c = (1, 2, 3, 4) - -#PY-4357 -c = 1, 2, 3 -a, b = c - -#PY-4360 -(a, b) = 1, 2, 3 -(a, b) = (1, 2, 3) - -#PY-4358 -a, b = [1, 2, 3] -a, b = 'str' -a, b = {1, 2, 3} -a, b = {1:2, 2: 3, 3:4} - -# PY-6315 -def test_tuple_slice(): - def f(): - return 1, 2, 3 - x, y = f()[:2] - -# PY-22224 -a, b = None diff --git a/python/testData/inspections/PyTupleAssignmentBalanceInspection/test.py b/python/testData/inspections/PyTupleAssignmentBalanceInspectionTest/py2.py similarity index 76% rename from python/testData/inspections/PyTupleAssignmentBalanceInspection/test.py rename to python/testData/inspections/PyTupleAssignmentBalanceInspectionTest/py2.py index 215a1180493c..aa80bcc221f5 100644 --- a/python/testData/inspections/PyTupleAssignmentBalanceInspection/test.py +++ b/python/testData/inspections/PyTupleAssignmentBalanceInspectionTest/py2.py @@ -1,4 +1,5 @@ a, b, c = 1, 2, 3, 4 +a, b, c = (1, 2, 3, 4) a, b, c = foo, bar a, b, c, d = 1, 2, 3, 4 a = 1, 2, 3, 4 diff --git a/python/testData/inspections/PyTupleAssignmentBalanceInspection3/test.py b/python/testData/inspections/PyTupleAssignmentBalanceInspectionTest/py3.py similarity index 78% rename from python/testData/inspections/PyTupleAssignmentBalanceInspection3/test.py rename to python/testData/inspections/PyTupleAssignmentBalanceInspectionTest/py3.py index 03d74b56eb9f..499293eaeafd 100644 --- a/python/testData/inspections/PyTupleAssignmentBalanceInspection3/test.py +++ b/python/testData/inspections/PyTupleAssignmentBalanceInspectionTest/py3.py @@ -7,7 +7,4 @@ a, b, c = 2 *a, b, c = 1, 2 b, c, *a, d = 1, 2 *a, b = 1, 2 -a, *b, c, *d = 1, 2, 3, 4, 5, 6 - -# PY-22224 -a, b = None \ No newline at end of file +a, *b, c, *d = 1, 2, 3, 4, 5, 6 \ No newline at end of file diff --git a/python/testData/inspections/PyTupleAssignmentBalanceInspectionTest/py4357.py b/python/testData/inspections/PyTupleAssignmentBalanceInspectionTest/py4357.py new file mode 100644 index 000000000000..1ee61875d91b --- /dev/null +++ b/python/testData/inspections/PyTupleAssignmentBalanceInspectionTest/py4357.py @@ -0,0 +1,2 @@ +c = 1, 2, 3 +a, b = c \ No newline at end of file diff --git a/python/testData/inspections/PyTupleAssignmentBalanceInspectionTest/py4358.py b/python/testData/inspections/PyTupleAssignmentBalanceInspectionTest/py4358.py new file mode 100644 index 000000000000..faceb4a7e518 --- /dev/null +++ b/python/testData/inspections/PyTupleAssignmentBalanceInspectionTest/py4358.py @@ -0,0 +1,4 @@ +a, b = [1, 2, 3] +a, b = 'str' +a, b = {1, 2, 3} +a, b = {1:2, 2: 3, 3:4} \ No newline at end of file diff --git a/python/testData/inspections/PyTupleAssignmentBalanceInspectionTest/py4360.py b/python/testData/inspections/PyTupleAssignmentBalanceInspectionTest/py4360.py new file mode 100644 index 000000000000..7f7e5a7b762e --- /dev/null +++ b/python/testData/inspections/PyTupleAssignmentBalanceInspectionTest/py4360.py @@ -0,0 +1,2 @@ +(a, b) = 1, 2, 3 +(a, b) = (1, 2, 3) \ No newline at end of file diff --git a/python/testData/inspections/PyTupleAssignmentBalanceInspectionTest/py6315.py b/python/testData/inspections/PyTupleAssignmentBalanceInspectionTest/py6315.py new file mode 100644 index 000000000000..f67929d17013 --- /dev/null +++ b/python/testData/inspections/PyTupleAssignmentBalanceInspectionTest/py6315.py @@ -0,0 +1,4 @@ +def test_tuple_slice(): + def f(): + return 1, 2, 3 + x, y = f()[:2] \ No newline at end of file diff --git a/python/testData/inspections/PyTupleAssignmentBalanceInspectionTest/unpackNonePy2.py b/python/testData/inspections/PyTupleAssignmentBalanceInspectionTest/unpackNonePy2.py new file mode 100644 index 000000000000..deeed270e95e --- /dev/null +++ b/python/testData/inspections/PyTupleAssignmentBalanceInspectionTest/unpackNonePy2.py @@ -0,0 +1 @@ +a, b = None \ No newline at end of file diff --git a/python/testData/inspections/PyTupleAssignmentBalanceInspectionTest/unpackNonePy3.py b/python/testData/inspections/PyTupleAssignmentBalanceInspectionTest/unpackNonePy3.py new file mode 100644 index 000000000000..deeed270e95e --- /dev/null +++ b/python/testData/inspections/PyTupleAssignmentBalanceInspectionTest/unpackNonePy3.py @@ -0,0 +1 @@ +a, b = None \ No newline at end of file diff --git a/python/testSrc/com/jetbrains/python/PythonInspectionsTest.java b/python/testSrc/com/jetbrains/python/PythonInspectionsTest.java index d2725abb33e3..04d7f86dc1e7 100644 --- a/python/testSrc/com/jetbrains/python/PythonInspectionsTest.java +++ b/python/testSrc/com/jetbrains/python/PythonInspectionsTest.java @@ -132,18 +132,6 @@ public class PythonInspectionsTest extends PyTestCase { doHighlightingTest(PyDictCreationInspection.class, LanguageLevel.PYTHON26); } - public void testPyTupleAssignmentBalanceInspection() { - doHighlightingTest(PyTupleAssignmentBalanceInspection.class); - } - - public void testPyTupleAssignmentBalanceInspection2() { - doHighlightingTest(PyTupleAssignmentBalanceInspection.class, LanguageLevel.PYTHON27); - } - - public void testPyTupleAssignmentBalanceInspection3() { - doHighlightingTest(PyTupleAssignmentBalanceInspection.class, LanguageLevel.PYTHON30); - } - public void testPyClassicStyleClassInspection() { doHighlightingTest(PyClassicStyleClassInspection.class); } diff --git a/python/testSrc/com/jetbrains/python/inspections/PyTupleAssignmentBalanceInspectionTest.java b/python/testSrc/com/jetbrains/python/inspections/PyTupleAssignmentBalanceInspectionTest.java new file mode 100644 index 000000000000..c336dea38677 --- /dev/null +++ b/python/testSrc/com/jetbrains/python/inspections/PyTupleAssignmentBalanceInspectionTest.java @@ -0,0 +1,68 @@ +/* + * Copyright 2000-2017 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.jetbrains.python.inspections; + +import com.jetbrains.python.fixtures.PyTestCase; +import com.jetbrains.python.psi.LanguageLevel; + +public class PyTupleAssignmentBalanceInspectionTest extends PyTestCase { + + public void testPy2() { + doTest(); + } + + public void testPy3() { + runWithLanguageLevel(LanguageLevel.PYTHON30, this::doTest); + } + + // PY-4357 + public void testPy4357() { + doTest(); + } + + // PY-4360 + public void testPy4360() { + doTest(); + } + + // PY-4358 + public void testPy4358() { + doTest(); + } + + // PY-6315 + public void testPy6315() { + doTest(); + } + + // PY-22224 + public void testUnpackNonePy2() { + runWithLanguageLevel(LanguageLevel.PYTHON27, this::doTest); + } + + // PY-22224 + public void testUnpackNonePy3() { + runWithLanguageLevel(LanguageLevel.PYTHON30, this::doTest); + } + + private void doTest() { + final String path = "inspections/PyTupleAssignmentBalanceInspectionTest/" + getTestName(true) + ".py"; + + myFixture.configureByFile(path); + myFixture.enableInspections(PyTupleAssignmentBalanceInspection.class); + myFixture.checkHighlighting(true, false, false); + } +}