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