Fix Python Console tests

This commit is contained in:
Alexander Koshevoy
2018-07-12 18:50:56 +03:00
parent 1edb285e65
commit a74398fb40
2 changed files with 13 additions and 7 deletions

View File

@@ -78,6 +78,8 @@ import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.*;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
/**
* @author traff
@@ -243,6 +245,8 @@ public class PythonConsoleView extends LanguageConsoleImpl implements Observable
public void executeInConsole(@NotNull final String code) {
CountDownLatch latch = new CountDownLatch(1);
TransactionGuard.submitTransaction(this, () -> {
final String codeToExecute = code.endsWith("\n") || myExecuteActionHandler.checkSingleLine(code) ? code : code + "\n";
DocumentEx document = getConsoleEditor().getDocument();
@@ -267,7 +271,16 @@ public class PythonConsoleView extends LanguageConsoleImpl implements Observable
getConsoleEditor().getCaretModel().moveToOffset(oldOffset);
}
});
latch.countDown();
});
try {
latch.await(1, TimeUnit.MINUTES);
}
catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}
public void executeStatement(@NotNull String statement, @NotNull final Key attributes) {

View File

@@ -2,7 +2,6 @@ package com.jetbrains.env.python;
import com.google.common.collect.Sets;
import com.jetbrains.env.PyEnvTestCase;
import com.jetbrains.env.Staging;
import com.jetbrains.env.python.console.PyConsoleTask;
import org.jetbrains.annotations.NotNull;
import org.junit.Assert;
@@ -20,7 +19,6 @@ import static org.junit.Assert.assertTrue;
*/
public class PythonConsoleTest extends PyEnvTestCase {
@Test
@Staging
public void testConsolePrint() {
runPythonTest(new PyConsoleTask() {
@Override
@@ -55,7 +53,6 @@ public class PythonConsoleTest extends PyEnvTestCase {
}
@Test
@Staging
public void testInterruptAsync() {
runPythonTest(new PyConsoleTask() {
@Override
@@ -80,7 +77,6 @@ public class PythonConsoleTest extends PyEnvTestCase {
}
@Test
@Staging
public void testLineByLineInput() {
runPythonTest(new PyConsoleTask() {
@Override
@@ -96,7 +92,6 @@ public class PythonConsoleTest extends PyEnvTestCase {
@Test
@Staging
public void testVariablesView() {
runPythonTest(new PyConsoleTask() {
@Override
@@ -112,7 +107,6 @@ public class PythonConsoleTest extends PyEnvTestCase {
}
@Test
@Staging //Thread leak
public void testCompoundVariable() {
runPythonTest(new PyConsoleTask() {
@Override
@@ -128,7 +122,6 @@ public class PythonConsoleTest extends PyEnvTestCase {
});
}
@Staging
@Test
public void testChangeVariable() {
runPythonTest(new PyConsoleTask() {