'ptk history/multiline'

This commit is contained in:
Konstantinos Tsakiltzidis 2016-06-22 23:17:33 +03:00
parent d4def76232
commit 201d068b72
2 changed files with 15 additions and 25 deletions

View file

@ -1,10 +1,9 @@
# -*- coding: utf-8 -*-
"""Tests for the PromptToolkitHistory class."""
import os
import sys
import nose
from nose.tools import assert_equal
import pytest
def is_prompt_toolkit_available():
try:
@ -14,8 +13,7 @@ def is_prompt_toolkit_available():
return False
if not is_prompt_toolkit_available():
from nose.plugins.skip import SkipTest
raise SkipTest('prompt_toolkit is not available')
pytest.skip(msg='prompt_toolkit is not available')
from xonsh.ptk.history import PromptToolkitHistory
@ -24,10 +22,6 @@ from xonsh.ptk.history import PromptToolkitHistory
def test_obj():
history_obj = PromptToolkitHistory(load_prev=False)
history_obj.append('line10')
yield assert_equal, ['line10'], history_obj.strings
yield assert_equal, 1, len(history_obj)
yield assert_equal, ['line10'], [x for x in history_obj]
if __name__ == '__main__':
nose.runmodule()
assert ['line10'] == history_obj.strings
assert len(history_obj) == 1
assert ['line10'] == [x for x in history_obj]

View file

@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
"""Tests sample inputs to PTK multiline and checks parser response"""
import nose
from nose.tools import assert_equal, with_setup
import pytest
from unittest.mock import MagicMock, patch
from prompt_toolkit.interface import CommandLineInterface
@ -17,7 +16,7 @@ def setup_module():
global cli
global carriage_return
global builtins
import builtins
builtins.__xonsh_env__ = Env()
@ -38,7 +37,7 @@ def teardown_module():
global cli
global carriage_return
global builtins
del indent_
del buffer
del bufaccept
@ -50,18 +49,18 @@ def test_colon_indent():
document = Document('for i in range(5):')
buffer.set_document(document)
carriage_return(buffer, cli)
assert_equal(buffer.document.current_line, indent_)
assert buffer.document.current_line == indent_
def test_dedent():
document = Document('\n'+indent_+'pass')
buffer.set_document(document)
carriage_return(buffer, cli)
assert_equal(buffer.document.current_line, '')
assert buffer.document.current_line == ''
document = Document('\n'+2*indent_+'continue')
buffer.set_document(document)
carriage_return(buffer, cli)
assert_equal(buffer.document.current_line,indent_)
assert buffer.document.current_line == indent_
def test_nodedent():
'''don't dedent if first line of buffer'''
@ -84,7 +83,7 @@ def test_continuation_line():
document = Document('\nsecond line')
buffer.set_document(document)
carriage_return(buffer, cli)
assert_equal(buffer.document.current_line, '')
assert buffer.document.current_line == ''
def test_trailing_slash():
mock = MagicMock(return_value = True)
@ -93,7 +92,7 @@ def test_trailing_slash():
buffer.set_document(document)
carriage_return(buffer, cli)
if not ON_WINDOWS:
assert_equal(buffer.document.current_line, '')
assert buffer.document.current_line == ''
else:
assert bufaccept.mock_calls is not None
@ -103,7 +102,7 @@ def test_cant_compile_newline():
document = Document('for i in (1, 2, ')
buffer.set_document(document)
carriage_return(buffer, cli)
assert_equal(buffer.document.current_line, '')
assert buffer.document.current_line == ''
def test_can_compile_and_executes():
mock = MagicMock(return_value = True)
@ -112,6 +111,3 @@ def test_can_compile_and_executes():
buffer.set_document(document)
carriage_return(buffer, cli)
assert bufaccept.mock_calls is not None
if __name__ == '__main__':
nose.runmodule()