from pyqode.qt import QtCore
from pyqode.qt.QtTest import QTest
from pyqode.core.api import TextHelper
from pyqode.core import modes
from test.helpers import editor_open


def get_mode(editor):
    return editor.modes.get(modes.SmartBackSpaceMode)


def test_enabled(editor):
    mode = get_mode(editor)
    assert mode.enabled
    mode.enabled = False
    mode.enabled = True


@editor_open(__file__)
def test_key_pressed(editor):
    QTest.qWait(1000)
    TextHelper(editor).goto_line(21, 4)
    QTest.qWait(2000)
    assert editor.textCursor().positionInBlock() == 4
    QTest.keyPress(editor, QtCore.Qt.Key_Backspace)
    QTest.qWait(2000)
    assert editor.textCursor().positionInBlock() == 0
    TextHelper(editor).goto_line(19, 5)
    QTest.qWait(2000)
    assert editor.textCursor().positionInBlock() == 5
    QTest.keyPress(editor, QtCore.Qt.Key_Backspace)
    QTest.qWait(2000)
    assert editor.textCursor().positionInBlock() == 4

    TextHelper(editor).goto_line(20, 0)
    QTest.qWait(2000)
    assert editor.textCursor().positionInBlock() == 0
    QTest.keyPress(editor, QtCore.Qt.Key_Backspace)
    QTest.qWait(2000)
    assert editor.textCursor().positionInBlock() == 28

from pyqode.qt import QtCore
from pyqode.qt.QtTest import QTest
from pyqode.core.api import TextHelper
from pyqode.core import modes
from test.helpers import editor_open


def get_mode(editor):
    return editor.modes.get(modes.SmartBackSpaceMode)


def test_enabled(editor):
    mode = get_mode(editor)
    assert mode.enabled
    mode.enabled = False
    mode.enabled = True


@editor_open(__file__)
def test_key_pressed(editor):
    QTest.qWait(1000)
    TextHelper(editor).goto_line(21, 4)
    # QTest.qWait(2000)
    assert editor.textCursor().positionInBlock() == 4
    QTest.keyPress(editor, QtCore.Qt.Key_Backspace)

Reduce test backspace, we just need to ensure it really eats tab_len spaces
Reduce test backspace, we just need to ensure it really eats tab_len spaces

  from pyqode.qt import QtCore
  from pyqode.qt.QtTest import QTest
  from pyqode.core.api import TextHelper
  from pyqode.core import modes
  from test.helpers import editor_open
  
  
  def get_mode(editor):
      return editor.modes.get(modes.SmartBackSpaceMode)
  
  
  def test_enabled(editor):
      mode = get_mode(editor)
      assert mode.enabled
      mode.enabled = False
      mode.enabled = True
  
  
  @editor_open(__file__)
  def test_key_pressed(editor):
      QTest.qWait(1000)
      TextHelper(editor).goto_line(21, 4)
-     QTest.qWait(2000)
+     # QTest.qWait(2000)
      assert editor.textCursor().positionInBlock() == 4
      QTest.keyPress(editor, QtCore.Qt.Key_Backspace)
-     QTest.qWait(2000)
-     assert editor.textCursor().positionInBlock() == 0
-     TextHelper(editor).goto_line(19, 5)
-     QTest.qWait(2000)
-     assert editor.textCursor().positionInBlock() == 5
-     QTest.keyPress(editor, QtCore.Qt.Key_Backspace)
-     QTest.qWait(2000)
-     assert editor.textCursor().positionInBlock() == 4
  
-     TextHelper(editor).goto_line(20, 0)
-     QTest.qWait(2000)
-     assert editor.textCursor().positionInBlock() == 0
-     QTest.keyPress(editor, QtCore.Qt.Key_Backspace)
-     QTest.qWait(2000)
-     assert editor.textCursor().positionInBlock() == 28
- 
Reduce test backspace, we just need to ensure it really eats tab_len spaces
## Code Before:
from pyqode.qt import QtCore
from pyqode.qt.QtTest import QTest
from pyqode.core.api import TextHelper
from pyqode.core import modes
from test.helpers import editor_open


def get_mode(editor):
    return editor.modes.get(modes.SmartBackSpaceMode)


def test_enabled(editor):
    mode = get_mode(editor)
    assert mode.enabled
    mode.enabled = False
    mode.enabled = True


@editor_open(__file__)
def test_key_pressed(editor):
    QTest.qWait(1000)
    TextHelper(editor).goto_line(21, 4)
    QTest.qWait(2000)
    assert editor.textCursor().positionInBlock() == 4
    QTest.keyPress(editor, QtCore.Qt.Key_Backspace)
    QTest.qWait(2000)
    assert editor.textCursor().positionInBlock() == 0
    TextHelper(editor).goto_line(19, 5)
    QTest.qWait(2000)
    assert editor.textCursor().positionInBlock() == 5
    QTest.keyPress(editor, QtCore.Qt.Key_Backspace)
    QTest.qWait(2000)
    assert editor.textCursor().positionInBlock() == 4

    TextHelper(editor).goto_line(20, 0)
    QTest.qWait(2000)
    assert editor.textCursor().positionInBlock() == 0
    QTest.keyPress(editor, QtCore.Qt.Key_Backspace)
    QTest.qWait(2000)
    assert editor.textCursor().positionInBlock() == 28

## Instruction:
Reduce test backspace, we just need to ensure it really eats tab_len spaces
## Code After:
from pyqode.qt import QtCore
from pyqode.qt.QtTest import QTest
from pyqode.core.api import TextHelper
from pyqode.core import modes
from test.helpers import editor_open


def get_mode(editor):
    return editor.modes.get(modes.SmartBackSpaceMode)


def test_enabled(editor):
    mode = get_mode(editor)
    assert mode.enabled
    mode.enabled = False
    mode.enabled = True


@editor_open(__file__)
def test_key_pressed(editor):
    QTest.qWait(1000)
    TextHelper(editor).goto_line(21, 4)
    # QTest.qWait(2000)
    assert editor.textCursor().positionInBlock() == 4
    QTest.keyPress(editor, QtCore.Qt.Key_Backspace)
