summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2021-03-26 12:42:03 +0100
committermathieui <mathieui@mathieui.net>2021-04-02 17:44:36 +0200
commitef772d8b2aaba697549b63173de9e0291691d11c (patch)
tree38b9aa63f667ad4bc784f26a4f2855daf2d39904 /test
parent84afe4938dfa40aff388e48c1c0b159469656839 (diff)
downloadpoezio-ef772d8b2aaba697549b63173de9e0291691d11c.tar.gz
poezio-ef772d8b2aaba697549b63173de9e0291691d11c.tar.bz2
poezio-ef772d8b2aaba697549b63173de9e0291691d11c.tar.xz
poezio-ef772d8b2aaba697549b63173de9e0291691d11c.zip
fix: failing tests
Diffstat (limited to 'test')
-rw-r--r--test/test_completion.py10
-rw-r--r--test/test_config.py2
-rw-r--r--test/test_tabs.py10
-rw-r--r--test/test_text_buffer.py4
-rw-r--r--test/test_windows.py20
-rw-r--r--test/test_xhtml.py6
6 files changed, 42 insertions, 10 deletions
diff --git a/test/test_completion.py b/test/test_completion.py
index 620b5658..1a970470 100644
--- a/test/test_completion.py
+++ b/test/test_completion.py
@@ -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
diff --git a/test/test_config.py b/test/test_config.py
index 262efc72..0a1c80ce 100644
--- a/test/test_config.py
+++ b/test/test_config.py
@@ -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')
diff --git a/test/test_tabs.py b/test/test_tabs.py
index 6989bd67..cb72340b 100644
--- a/test/test_tabs.py
+++ b/test/test_tabs.py
@@ -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
diff --git a/test/test_text_buffer.py b/test/test_text_buffer.py
index 65c6d9bf..3daf54d4 100644
--- a/test/test_text_buffer.py
+++ b/test/test_text_buffer.py
@@ -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]
-
diff --git a/test/test_windows.py b/test/test_windows.py
index af1b9d4a..3be96172 100644
--- a/test/test_windows.py
+++ b/test/test_windows.py
@@ -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':
diff --git a/test/test_xhtml.py b/test/test_xhtml.py
index 472991c6..333a10c3 100644
--- a/test/test_xhtml.py
+++ b/test/test_xhtml.py
@@ -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