diff --git a/python/testData/inspections/AddGlobalExistingStatement.py b/python/testData/inspections/AddGlobalExistingStatement.py new file mode 100644 index 000000000000..17a6ee57c580 --- /dev/null +++ b/python/testData/inspections/AddGlobalExistingStatement.py @@ -0,0 +1,9 @@ +a = 1 + +def foo(): + global b + print a + a = 2 + print a + +foo() diff --git a/python/testData/inspections/AddGlobalExistingStatement_after.py b/python/testData/inspections/AddGlobalExistingStatement_after.py new file mode 100644 index 000000000000..23aedf9f1ba9 --- /dev/null +++ b/python/testData/inspections/AddGlobalExistingStatement_after.py @@ -0,0 +1,9 @@ +a = 1 + +def foo(): + global b, a + print a + a = 2 + print a + +foo() diff --git a/python/testData/inspections/AddGlobalStatement.py b/python/testData/inspections/AddGlobalStatement.py new file mode 100644 index 000000000000..ca60f05341bf --- /dev/null +++ b/python/testData/inspections/AddGlobalStatement.py @@ -0,0 +1,8 @@ +a = 1 + +def foo(): + print a + a = 2 + print a + +foo() diff --git a/python/testData/inspections/AddGlobalStatement_after.py b/python/testData/inspections/AddGlobalStatement_after.py new file mode 100644 index 000000000000..79add5148023 --- /dev/null +++ b/python/testData/inspections/AddGlobalStatement_after.py @@ -0,0 +1,9 @@ +a = 1 + +def foo(): + global a + print a + a = 2 + print a + +foo() \ No newline at end of file diff --git a/python/testSrc/com/jetbrains/python/PyQuickFixTest.java b/python/testSrc/com/jetbrains/python/PyQuickFixTest.java index 87dbec0b96fc..158c3ebf1a24 100644 --- a/python/testSrc/com/jetbrains/python/PyQuickFixTest.java +++ b/python/testSrc/com/jetbrains/python/PyQuickFixTest.java @@ -97,6 +97,16 @@ public class PyQuickFixTest extends PyLightFixtureTestCase { PyBundle.message("QFIX.classic.class.transform"), true, true); } + public void testAddGlobalQuickFix() throws Exception { + doInspectionTest("AddGlobalStatement.py", PyUnboundLocalVariableInspection.class, + PyBundle.message("QFIX.add.global"), true, true); + } + + public void testAddGlobalExistingQuickFix() throws Exception { + doInspectionTest("AddGlobalExistingStatement.py", PyUnboundLocalVariableInspection.class, + PyBundle.message("QFIX.add.global"), true, true); + } + protected void doInspectionTest(@NonNls String testFileName, final Class inspectionClass, @NonNls String quickFixName,