extracted augment assignment tests

This commit is contained in:
Ekaterina Tuzova
2013-10-10 17:45:17 +04:00
parent dd75fa1844
commit ddb0d98b13
21 changed files with 91 additions and 40 deletions

View File

@@ -0,0 +1,2 @@
exp = 2
<weak_warning descr="Assignment can be replaced with augmented assignment">value = value <caret>/ (10**exp) #comment</weak_warning>

View File

@@ -0,0 +1,2 @@
exp = 2
value /= 10 ** exp#comment

View File

@@ -0,0 +1,5 @@
def retStr():
return ''
s1 = ''
<weak_warning descr="Assignment can be replaced with augmented assignment">s1 = s1 <caret>+ retStr()</weak_warning>

View File

@@ -0,0 +1,5 @@
def retStr():
return ''
s1 = ''
s1 += retStr()

View File

@@ -0,0 +1 @@
<weak_warning descr="Assignment can be replaced with augmented assignment">request = request + " FROM bugs WHERE bug_id = %s" % (str(bug_id))</weak_warning>

View File

@@ -0,0 +1 @@
request += " FROM bugs WHERE bug_id = %s" % (str(bug_id))

View File

@@ -0,0 +1,3 @@
v = 0
f = 1
<weak_warning descr="Assignment can be replaced with augmented assignment">v = <caret>f + v</weak_warning>

View File

@@ -0,0 +1,3 @@
v = 0
f = 1
v += f

View File

@@ -0,0 +1 @@
<weak_warning descr="Assignment can be replaced with augmented assignment">var = <caret>var + 3</weak_warning>

View File

@@ -0,0 +1 @@
var += 3

View File

@@ -0,0 +1,3 @@
current_sum = 1
numbers = [1, 2, 3]
<weak_warning descr="Assignment can be replaced with augmented assignment">current_sum = current_sum + numbers[0]</weak_warning>

View File

@@ -0,0 +1,3 @@
current_sum = 1
numbers = [1, 2, 3]
current_sum += numbers[0]

View File

@@ -0,0 +1,4 @@
class A:
x = 3
a = A()
<weak_warning descr="Assignment can be replaced with augmented assignment">a.x = a.x +<caret> 1</weak_warning>

View File

@@ -0,0 +1,4 @@
class A:
x = 3
a = A()
a.x += 1

View File

@@ -194,41 +194,6 @@ public class PyQuickFixTest extends PyTestCase {
PyBundle.message("QFIX.redundant.parentheses"), true, true);
}
public void testAugmentAssignment() { // PY-1415
doInspectionTest("AugmentAssignment.py", PyAugmentAssignmentInspection.class,
PyBundle.message("QFIX.augment.assignment"), true, true);
}
public void testAugmentAssignmentWithContext() { // PY-2481
doInspectionTest("AugmentAssignmentWithContext.py", PyAugmentAssignmentInspection.class,
PyBundle.message("QFIX.augment.assignment"), true, true);
}
public void testAugmentAssignmentPerc() { // PY-3197
doInspectionTest("AugmentAssignmentPerc.py", PyAugmentAssignmentInspection.class,
PyBundle.message("QFIX.augment.assignment"), true, true);
}
public void testAugmentAssignment1() { // PY-5037
doInspectionTest("AugmentAssignment1.py", PyAugmentAssignmentInspection.class,
PyBundle.message("QFIX.augment.assignment"), true, true);
}
public void testAugmentAssignment2() { // PY-6331
doInspectionTest("AugmentAssignment2.py", PyAugmentAssignmentInspection.class,
PyBundle.message("QFIX.augment.assignment"), true, true);
}
public void testAugmentAssignmentFunction() { // PY-6678
doInspectionTest("AugmentAssignmentFunction.py", PyAugmentAssignmentInspection.class,
PyBundle.message("QFIX.augment.assignment"), true, true);
}
public void testAugmentAssignmentSubscription() { // PY-7715
doInspectionTest("AugmentAssignmentFunction.py", PyAugmentAssignmentInspection.class,
PyBundle.message("QFIX.augment.assignment"), true, true);
}
public void testChainedComparisons() { // PY-1020
doInspectionTest("ChainedComparisons.py", PyChainedComparisonsInspection.class,
PyBundle.message("QFIX.chained.comparison"), true, true);

View File

@@ -1,5 +1,7 @@
package com.jetbrains.python;
package com.jetbrains.python.quickFixes;
import com.jetbrains.python.PyBundle;
import com.jetbrains.python.PyQuickFixTestCase;
import com.jetbrains.python.inspections.PyUnresolvedReferencesInspection;
/**

View File

@@ -1,5 +1,7 @@
package com.jetbrains.python;
package com.jetbrains.python.quickFixes;
import com.jetbrains.python.PyBundle;
import com.jetbrains.python.PyQuickFixTestCase;
import com.jetbrains.python.inspections.PyClassHasNoInitInspection;
import com.jetbrains.python.inspections.PyUnresolvedReferencesInspection;

View File

@@ -0,0 +1,38 @@
package com.jetbrains.python.quickFixes;
import com.jetbrains.python.PyQuickFixTestCase;
import com.jetbrains.python.inspections.PyAugmentAssignmentInspection;
/**
* User: ktisha
*/
public class PyAugmentAssignmentQuickFixTest extends PyQuickFixTestCase {
public void testSimple() { // PY-1415
doInspectionTest(PyAugmentAssignmentInspection.class);
}
public void testWithContext() { // PY-2481
doInspectionTest(PyAugmentAssignmentInspection.class);
}
public void testPercent() { // PY-3197
doInspectionTest(PyAugmentAssignmentInspection.class);
}
public void testDivision() { // PY-5037
doInspectionTest(PyAugmentAssignmentInspection.class);
}
public void testReferences() { // PY-6331
doInspectionTest(PyAugmentAssignmentInspection.class);
}
public void testFunction() { // PY-6678
doInspectionTest(PyAugmentAssignmentInspection.class);
}
public void testSubscription() { // PY-7715
doInspectionTest(PyAugmentAssignmentInspection.class);
}
}

View File

@@ -1,5 +1,7 @@
package com.jetbrains.python;
package com.jetbrains.python.quickFixes;
import com.jetbrains.python.PyBundle;
import com.jetbrains.python.PyQuickFixTestCase;
import com.jetbrains.python.inspections.PyMethodMayBeStaticInspection;
/**

View File

@@ -1,5 +1,7 @@
package com.jetbrains.python;
package com.jetbrains.python.quickFixes;
import com.jetbrains.python.PyBundle;
import com.jetbrains.python.PyQuickFixTestCase;
import com.jetbrains.python.inspections.PyMethodMayBeStaticInspection;
/**

View File

@@ -1,6 +1,8 @@
package com.jetbrains.python;
package com.jetbrains.python.quickFixes;
import com.intellij.testFramework.TestDataPath;
import com.jetbrains.python.PyBundle;
import com.jetbrains.python.PyQuickFixTestCase;
import com.jetbrains.python.inspections.PyAttributeOutsideInitInspection;
/**