fix: failing tests
This commit is contained in:
parent
84afe4938d
commit
ef772d8b2a
6 changed files with 42 additions and 10 deletions
|
@ -5,15 +5,19 @@ Test the completions methods on an altered input object.
|
||||||
import string
|
import string
|
||||||
import pytest
|
import pytest
|
||||||
import random
|
import random
|
||||||
|
from poezio import config
|
||||||
|
from poezio.windows import Input
|
||||||
|
|
||||||
|
|
||||||
class ConfigShim(object):
|
class ConfigShim(object):
|
||||||
def get(self, *args, **kwargs):
|
def get(self, *args, **kwargs):
|
||||||
return ''
|
return ''
|
||||||
|
def getbool(self, *args, **kwargs):
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
from poezio import config
|
|
||||||
config.config = ConfigShim()
|
config.config = ConfigShim()
|
||||||
|
|
||||||
from poezio.windows import Input
|
|
||||||
|
|
||||||
class SubInput(Input):
|
class SubInput(Input):
|
||||||
def resize(self, *args, **kwargs):
|
def resize(self, *args, **kwargs):
|
||||||
|
@ -26,6 +30,8 @@ class SubInput(Input):
|
||||||
|
|
||||||
@pytest.fixture(scope="function")
|
@pytest.fixture(scope="function")
|
||||||
def input_obj():
|
def input_obj():
|
||||||
|
from poezio.windows import base_wins
|
||||||
|
base_wins.TAB_WIN = True
|
||||||
obj = SubInput()
|
obj = SubInput()
|
||||||
obj.reset_completion()
|
obj.reset_completion()
|
||||||
return obj
|
return obj
|
||||||
|
|
|
@ -10,6 +10,7 @@ import pytest
|
||||||
|
|
||||||
from poezio import config
|
from poezio import config
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="module")
|
@pytest.fixture(scope="module")
|
||||||
def config_obj():
|
def config_obj():
|
||||||
file_ = tempfile.NamedTemporaryFile(delete=False)
|
file_ = tempfile.NamedTemporaryFile(delete=False)
|
||||||
|
@ -18,6 +19,7 @@ def config_obj():
|
||||||
del conf
|
del conf
|
||||||
os.unlink(file_.name)
|
os.unlink(file_.name)
|
||||||
|
|
||||||
|
|
||||||
class TestConfigSimple(object):
|
class TestConfigSimple(object):
|
||||||
def test_get_set(self, config_obj):
|
def test_get_set(self, config_obj):
|
||||||
config_obj.set_and_save('test', value='coucou')
|
config_obj.set_and_save('test', value='coucou')
|
||||||
|
|
|
@ -12,9 +12,17 @@ class DummyTab(Tab):
|
||||||
count = 0
|
count = 0
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.name = 'dummy%s' % self.count
|
self._name = 'dummy%s' % self.count
|
||||||
DummyTab.count += 1
|
DummyTab.count += 1
|
||||||
|
|
||||||
|
@property
|
||||||
|
def name(self):
|
||||||
|
return self._name
|
||||||
|
|
||||||
|
@name.setter
|
||||||
|
def name(self, value):
|
||||||
|
self._name = value
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def reset():
|
def reset():
|
||||||
DummyTab.count = 0
|
DummyTab.count = 0
|
||||||
|
|
|
@ -20,6 +20,7 @@ from poezio.ui.types import (
|
||||||
def buf2048():
|
def buf2048():
|
||||||
return TextBuffer(2048)
|
return TextBuffer(2048)
|
||||||
|
|
||||||
|
|
||||||
@fixture(scope='function')
|
@fixture(scope='function')
|
||||||
def msgs_nojoin():
|
def msgs_nojoin():
|
||||||
msg1 = Message('1', 'q')
|
msg1 = Message('1', 'q')
|
||||||
|
@ -35,6 +36,7 @@ def msgs_noleave():
|
||||||
msg4 = Message('4', 'f')
|
msg4 = Message('4', 'f')
|
||||||
return [join, msg3, msg4]
|
return [join, msg3, msg4]
|
||||||
|
|
||||||
|
|
||||||
@fixture(scope='function')
|
@fixture(scope='function')
|
||||||
def msgs_doublejoin():
|
def msgs_doublejoin():
|
||||||
join = MucOwnJoinMessage('join')
|
join = MucOwnJoinMessage('join')
|
||||||
|
@ -43,6 +45,7 @@ def msgs_doublejoin():
|
||||||
join2 = MucOwnJoinMessage('join')
|
join2 = MucOwnJoinMessage('join')
|
||||||
return [join, msg1, msg2, join2]
|
return [join, msg1, msg2, join2]
|
||||||
|
|
||||||
|
|
||||||
def test_last_message(buf2048):
|
def test_last_message(buf2048):
|
||||||
msg = BaseMessage('toto')
|
msg = BaseMessage('toto')
|
||||||
buf2048.add_message(BaseMessage('titi'))
|
buf2048.add_message(BaseMessage('titi'))
|
||||||
|
@ -195,4 +198,3 @@ def test_add_history_empty(buf2048):
|
||||||
buf2048.add_message(msg1)
|
buf2048.add_message(msg1)
|
||||||
buf2048.add_history_messages([msg2, msg3, msg4])
|
buf2048.add_history_messages([msg2, msg3, msg4])
|
||||||
assert buf2048.messages == [msg2, msg3, msg4, msg1]
|
assert buf2048.messages == [msg2, msg3, msg4, msg1]
|
||||||
|
|
||||||
|
|
|
@ -1,22 +1,32 @@
|
||||||
import pytest
|
import pytest
|
||||||
|
from poezio.windows import Input, HistoryInput, MessageInput
|
||||||
|
from poezio import config
|
||||||
|
|
||||||
class ConfigShim(object):
|
|
||||||
|
class ConfigShim:
|
||||||
def get(self, *args, **kwargs):
|
def get(self, *args, **kwargs):
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
from poezio import config
|
def getbool(self, *args, **kwargs):
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
config.config = ConfigShim()
|
config.config = ConfigShim()
|
||||||
|
|
||||||
from poezio.windows import Input, HistoryInput, MessageInput
|
|
||||||
|
|
||||||
class SubInput(Input):
|
class SubInput(Input):
|
||||||
|
|
||||||
def rewrite_text(self, *args, **kwargs):
|
def rewrite_text(self, *args, **kwargs):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def input():
|
def input():
|
||||||
|
from poezio.windows import base_wins
|
||||||
|
base_wins.TAB_WIN = True # The value is not relevant
|
||||||
return SubInput()
|
return SubInput()
|
||||||
|
|
||||||
|
|
||||||
class TestInput(object):
|
class TestInput(object):
|
||||||
|
|
||||||
def test_do_command(self, input):
|
def test_do_command(self, input):
|
||||||
|
@ -29,9 +39,9 @@ class TestInput(object):
|
||||||
assert input.text == 'acoucou'
|
assert input.text == 'acoucou'
|
||||||
|
|
||||||
def test_empty(self, input):
|
def test_empty(self, input):
|
||||||
assert input.is_empty() == True
|
assert input.is_empty()
|
||||||
input.do_command('a')
|
input.do_command('a')
|
||||||
assert input.is_empty() == False
|
assert not input.is_empty()
|
||||||
|
|
||||||
def test_key_left(self, input):
|
def test_key_left(self, input):
|
||||||
for char in 'this is a line':
|
for char in 'this is a line':
|
||||||
|
|
|
@ -8,11 +8,15 @@ import poezio.xhtml
|
||||||
from poezio.xhtml import (poezio_colors_to_html, xhtml_to_poezio_colors,
|
from poezio.xhtml import (poezio_colors_to_html, xhtml_to_poezio_colors,
|
||||||
_parse_css as parse_css, clean_text)
|
_parse_css as parse_css, clean_text)
|
||||||
|
|
||||||
class ConfigShim(object):
|
|
||||||
|
class ConfigShim:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.value = True
|
self.value = True
|
||||||
def get(self, *args, **kwargs):
|
def get(self, *args, **kwargs):
|
||||||
return self.value
|
return self.value
|
||||||
|
def getbool(self, *args, **kwargs):
|
||||||
|
return self.value
|
||||||
|
|
||||||
|
|
||||||
config = ConfigShim()
|
config = ConfigShim()
|
||||||
poezio.xhtml.config = config
|
poezio.xhtml.config = config
|
||||||
|
|
Loading…
Reference in a new issue