From 99f755531b36f9d760c60cf77481550e9bcd2c75 Mon Sep 17 00:00:00 2001 From: Mikhail Golubev Date: Mon, 25 Apr 2016 16:19:54 +0200 Subject: [PATCH] Fix blinking test testImportsFromTypingUnusedInTypeComments Due to non-deterministic order of test execution (in particular if CythonParsingTest has been executed before PyOptimizeImportsTest) sometimes PyDocstringTokenSetContributor was registered via EP, but wan't taken into account in the cached static instance of PythonDialectTokenSetProvider. Since reference expressions inside injected fragments have element type DOC_REFERENCE and the latter wasn't part of expression token set, that assertion in PySubscriptionExpression#getOperand failed. --- .../com/jetbrains/python/PyOptimizeImportsTest.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/python/testSrc/com/jetbrains/python/PyOptimizeImportsTest.java b/python/testSrc/com/jetbrains/python/PyOptimizeImportsTest.java index 9346c602c600..668b53d84186 100644 --- a/python/testSrc/com/jetbrains/python/PyOptimizeImportsTest.java +++ b/python/testSrc/com/jetbrains/python/PyOptimizeImportsTest.java @@ -23,6 +23,14 @@ import com.jetbrains.python.fixtures.PyTestCase; * @author yole */ public class PyOptimizeImportsTest extends PyTestCase { + + @Override + protected void setUp() throws Exception { + super.setUp(); + // importsFromTypingUnusedInTypeComments depends on registered TokenSetContributors + PythonDialectsTokenSetProvider.reset(); + } + public void testSimple() { doTest(); }