package com.jetbrains.python;

import com.intellij.codeInsight.editorActions.SelectWordHandler;
import com.intellij.ide.DataManager;
import com.intellij.testFramework.LightCodeInsightTestCase;
import org.jetbrains.annotations.NonNls;

import java.io.File;

/**
 * @author yole
 */
public class PySelectWordTest extends LightCodeInsightTestCase {
  public void testWord() throws Exception {
    doTest();
  }

  private void doTest() throws Exception {
    @NonNls final String path = getTestName(true);
    configureByFile(path + "/before.py");
    int i = 1;
    while (true) {
      @NonNls String resultPath = path + "/after" + i + ".py";
      if (new File(getTestDataPath() + resultPath).exists()) {
        performAction();
        //System.out.println("comparing with "+resultPath);
        checkResultByFile("Step " + i, resultPath, false);
        i++;
      }
      else {
        break;
      }
    }
    assertTrue(i>1);
  }

  private void performAction() {
    SelectWordHandler action = new SelectWordHandler(null);
    action.execute(getEditor(), DataManager.getInstance().getDataContext());
  }

  @Override
  protected String getTestDataPath() {
    return PythonTestUtil.getTestDataPath() + "/selectWord/";
  }
}

@@ -141,47 +141,48 @@
 com.
-intellij.testFramework.LightCodeInsight
+jetbrains.python.fixtures.PyLightFixture
 Test
@@ -317,24 +317,22 @@
 nds 
+Py
 Light
-CodeInsight
+Fixture
 Test
@@ -440,24 +440,70 @@
 Exception %7B%0A
+    myFixture.copyDirectoryToProject(%22%22, %22%22);%0A
     @NonNls 
@@ -545,16 +545,26 @@
 e);%0A    
+myFixture.
 configur
@@ -846,16 +846,26 @@
         
+myFixture.
 checkRes
@@ -878,21 +878,8 @@
 ile(
-%22Step %22 + i, 
 resu
@@ -977,9 +977,11 @@
 ue(i
-%3E
+ %3E 
 1);%0A
@@ -1078,16 +1078,16 @@
 (null);%0A
-
     acti
@@ -1097,16 +1097,26 @@
 execute(
+myFixture.
 getEdito

convert test to PyLightFixtureTestCase