Skip to content

Commit cd1f07d

Browse files
Fix tests
1 parent aa2723e commit cd1f07d

2 files changed

Lines changed: 41 additions & 55 deletions

File tree

pyqode/python/panels/quick_doc.py

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -94,32 +94,31 @@ def _on_action_quick_doc_triggered(self):
9494
def _on_results_available(self, results):
9595
self._reset_stylesheet()
9696
self.setVisible(True)
97-
if results:
98-
if len(results) and results[0] != "":
99-
string = "\n\n".join(results)
100-
string = publish_parts(
101-
string, writer_name='html',
102-
settings_overrides={'output_encoding': 'unicode'})[
103-
'html_body']
104-
string = string.replace('colspan="2"', 'colspan="0"')
105-
string = string.replace("<th ", '<th align="left" ')
106-
string = string.replace(
107-
'</tr>\n<tr class="field"><td>&nbsp;</td>', '')
108-
if string:
109-
skip_error_msg = False
110-
lines = []
111-
for l in string.splitlines():
112-
if (l.startswith('<div class="system-message"') or
113-
l.startswith(
114-
'<div class="last system-message"')):
115-
skip_error_msg = True
116-
continue
117-
if skip_error_msg:
118-
if l.endswith('</div>'):
119-
skip_error_msg = False
120-
else:
121-
lines.append(l)
122-
self.text_edit.setText('\n'.join(lines))
123-
return
124-
else:
125-
self.text_edit.setText("Documentation not found")
97+
if len(results) and results[0] != "":
98+
string = "\n\n".join(results)
99+
string = publish_parts(
100+
string, writer_name='html',
101+
settings_overrides={'output_encoding': 'unicode'})[
102+
'html_body']
103+
string = string.replace('colspan="2"', 'colspan="0"')
104+
string = string.replace("<th ", '<th align="left" ')
105+
string = string.replace(
106+
'</tr>\n<tr class="field"><td>&nbsp;</td>', '')
107+
if string:
108+
skip_error_msg = False
109+
lines = []
110+
for l in string.splitlines():
111+
if (l.startswith('<div class="system-message"') or
112+
l.startswith(
113+
'<div class="last system-message"')):
114+
skip_error_msg = True
115+
continue
116+
if skip_error_msg:
117+
if l.endswith('</div>'):
118+
skip_error_msg = False
119+
else:
120+
lines.append(l)
121+
self.text_edit.setText('\n'.join(lines))
122+
return
123+
else:
124+
self.text_edit.setText("Documentation not found")

test/test_backend/test_workers.py

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ def test_calltips():
1717
'column': len('open('),
1818
'path': None
1919
}
20-
status, results = workers.calltips(data)
21-
assert status is True
20+
results = workers.calltips(data)
2221
assert len(results) == 6
2322

2423

@@ -29,8 +28,7 @@ def test_calltips_with_closing_paren():
2928
'column': len('open()'),
3029
'path': None
3130
}
32-
status, results = workers.calltips(data)
33-
assert status is False
31+
results = workers.calltips(data)
3432
assert len(results) == 0
3533

3634

@@ -41,8 +39,7 @@ def test_goto_assignments():
4139
'column': len('foo = 10;print(foo)') - 1,
4240
'path': None
4341
}
44-
status, results = workers.goto_assignments(data)
45-
assert status is True
42+
results = workers.goto_assignments(data)
4643
assert len(results) == 1
4744
definition = results[0]
4845
module, line, column, full_name = definition
@@ -55,8 +52,7 @@ def test_goto_assignments():
5552
'column': len('foo = 10;print(foo)'),
5653
'path': None
5754
}
58-
status, results = workers.goto_assignments(data)
59-
assert status is True
55+
results = workers.goto_assignments(data)
6056
assert len(results) == 0
6157

6258

@@ -65,8 +61,7 @@ def test_defined_names():
6561
filename = __file__
6662
with open(filename, 'r', encoding='utf-8') as file:
6763
code = file.read()
68-
status, results = workers.defined_names({'code': code, 'path': filename})
69-
assert status is True
64+
results = workers.defined_names({'code': code, 'path': filename})
7065
assert len(results)
7166
definitions = []
7267
for i, definition in enumerate(results):
@@ -79,8 +74,7 @@ def test_defined_names():
7974
# now that the code changed, defined_names should return
8075
# (True, [xxx, yyy, ...])
8176
code += "\ndef foo():\n print('bar')"
82-
status, results = workers.defined_names({'code': code, 'path': filename})
83-
assert status is True
77+
results = workers.defined_names({'code': code, 'path': filename})
8478
assert len(results)
8579

8680

@@ -91,50 +85,43 @@ def test_quick_doc():
9185
'column': 1,
9286
'path': None
9387
}
94-
status, results = workers.quick_doc(data)
95-
assert status is True
88+
results = workers.quick_doc(data)
9689
assert len(results) == 1
9790
assert isinstance(results[0], str)
9891

9992

10093
def test_run_pep8():
101-
status, messages = workers.run_pep8(
94+
messages = workers.run_pep8(
10295
{'code': 'print("foo")\n', 'path': None})
103-
assert status is True
10496
assert len(messages) == 0
10597

106-
status, messages = workers.run_pep8(
98+
messages = workers.run_pep8(
10799
{'code': 'print("foo"); print("bar")\n', 'path': None})
108-
assert status is True
109100
assert len(messages) == 1
110101
assert messages[0][2] == 0
111102

112103

113104
def test_run_frosted():
114-
status, messages = workers.run_frosted(
105+
messages = workers.run_frosted(
115106
{'code': None, 'path': __file__, 'encoding': 'utf-8'})
116-
assert status is False
117107
assert len(messages) == 0
118108

119109
# OK
120-
status, messages = workers.run_frosted(
110+
messages = workers.run_frosted(
121111
{'code': 'print("foo")\n', 'path': __file__, 'encoding': 'utf-8'})
122-
assert status is True
123112
assert len(messages) == 0
124113

125114
# Syntax error
126-
status, messages = workers.run_frosted(
115+
messages = workers.run_frosted(
127116
{'code': 'print("foo\n', 'path': __file__,
128117
'encoding': 'utf-8'})
129-
assert status is True
130118
assert len(messages) == 1
131119
assert messages[0][2] == 0
132120

133121
# unused import
134-
status, messages = workers.run_frosted(
122+
messages = workers.run_frosted(
135123
{'code': 'import sys; print("foo");\n', 'path': __file__,
136124
'encoding': 'utf-8'})
137-
assert status is True
138125
assert len(messages) == 1
139126
msg, status, line = messages[0]
140127
assert 'sys imported but unused' in msg.lower()

0 commit comments

Comments
 (0)