diff --git a/python/testData/highlighting/breakInFinallyBlock.py b/python/testData/highlighting/breakInFinallyBlock.py
new file mode 100644
index 000000000000..0d809baaa540
--- /dev/null
+++ b/python/testData/highlighting/breakInFinallyBlock.py
@@ -0,0 +1,5 @@
+while True:
+ try:
+ print("a")
+ finally:
+ break
\ No newline at end of file
diff --git a/python/testData/highlighting/breakInFinallyBlockBefore314.py b/python/testData/highlighting/breakInFinallyBlockBefore314.py
new file mode 100644
index 000000000000..bbc63509c8dd
--- /dev/null
+++ b/python/testData/highlighting/breakInFinallyBlockBefore314.py
@@ -0,0 +1,5 @@
+while True:
+ try:
+ print("a")
+ finally:
+ break
\ No newline at end of file
diff --git a/python/testData/highlighting/returnInFinallyBlock.py b/python/testData/highlighting/returnInFinallyBlock.py
new file mode 100644
index 000000000000..b28c3b8c528a
--- /dev/null
+++ b/python/testData/highlighting/returnInFinallyBlock.py
@@ -0,0 +1,5 @@
+def foo():
+ try:
+ pass
+ finally:
+ return
\ No newline at end of file
diff --git a/python/testData/highlighting/returnInFinallyBlockBefore314.py b/python/testData/highlighting/returnInFinallyBlockBefore314.py
new file mode 100644
index 000000000000..e6fa44855cb7
--- /dev/null
+++ b/python/testData/highlighting/returnInFinallyBlockBefore314.py
@@ -0,0 +1,5 @@
+def foo():
+ try:
+ pass
+ finally:
+ return
\ No newline at end of file
diff --git a/python/testSrc/com/jetbrains/python/PythonHighlightingTest.java b/python/testSrc/com/jetbrains/python/PythonHighlightingTest.java
index b8aea21d8a27..521746e4778e 100644
--- a/python/testSrc/com/jetbrains/python/PythonHighlightingTest.java
+++ b/python/testSrc/com/jetbrains/python/PythonHighlightingTest.java
@@ -97,6 +97,26 @@ public class PythonHighlightingTest extends PyTestCase {
doTest(LanguageLevel.PYTHON38, false, false);
}
+ // PY-80237
+ public void testBreakInFinallyBlockBefore314() {
+ doTest(LanguageLevel.PYTHON313, false, false);
+ }
+
+ // PY-80237
+ public void testBreakInFinallyBlock() {
+ doTest(LanguageLevel.PYTHON314, false, false);
+ }
+
+ // PY-80237
+ public void testReturnInFinallyBlockBefore314() {
+ doTest(LanguageLevel.PYTHON313, false, false);
+ }
+
+ // PY-80237
+ public void testReturnInFinallyBlock() {
+ doTest(LanguageLevel.PYTHON314, false, false);
+ }
+
public void testReturnWithArgumentsInGenerator() {
doTest();
}
diff --git a/python/testSrc/com/jetbrains/python/inspections/Py3CompatibilityInspectionTest.java b/python/testSrc/com/jetbrains/python/inspections/Py3CompatibilityInspectionTest.java
index 51334869ddf9..31efe20840aa 100644
--- a/python/testSrc/com/jetbrains/python/inspections/Py3CompatibilityInspectionTest.java
+++ b/python/testSrc/com/jetbrains/python/inspections/Py3CompatibilityInspectionTest.java
@@ -16,29 +16,34 @@
package com.jetbrains.python.inspections;
import com.jetbrains.python.fixtures.PyInspectionTestCase;
+import com.jetbrains.python.psi.LanguageLevel;
import org.jetbrains.annotations.NotNull;
public class Py3CompatibilityInspectionTest extends PyInspectionTestCase {
// PY-80237
public void testBreakInFinallyBlock() {
- doTestByText("""
- while True:
- try:
- print("a")
- finally:
- break"""
+ runWithLanguageLevel(
+ LanguageLevel.PYTHON313,
+ () -> doTestByText("""
+ while True:
+ try:
+ print("a")
+ finally:
+ break""")
);
}
// PY-80237
public void testReturnInFinallyBlock() {
- doTestByText("""
- def foo():
- try:
- pass
- finally:
- return"""
+ runWithLanguageLevel(
+ LanguageLevel.PYTHON313,
+ () -> doTestByText("""
+ def foo():
+ try:
+ pass
+ finally:
+ return""")
);
}