Skip to content

Commit a3b99db

Browse files
Kweditor tests (#2600)
* Experimental unit test for kweditor * Increase unit tests, fix 2 issues * Increases tests. One test fails with invoke but not with PyCharm * Try to fix running all tests (no success) * Improve code and unit tests * Increase unit tests * Increase tests, increase fails * Remove debug info * Add pytest-order to requirements. Unit tests run now with desired order, but still fails * Increase unit tests, fix 2 issues * Increases tests. One test fails with invoke but not with PyCharm * Try to fix running all tests (no success) * Improve code and unit tests * Add pytest-order to requirements. Unit tests run now with desired order, but still fails * Improves tests call by isolating a test. Fix tool mkhtml * Restore moving to right cell after editing cell * Improve text editor variable creator, cursor position
1 parent aba7e54 commit a3b99db

File tree

9 files changed

+32
-20
lines changed

9 files changed

+32
-20
lines changed

CHANGELOG.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ and this project adheres to http://semver.org/spec/v2.0.0.html[Semantic Versioni
1414

1515
=== Changed
1616

17+
- Changed ``tasks.py`` to test ``utest/application/test_app_main.py`` isolated from the other tests
1718
- Improve auto-suggestions of keywords in Grid Editor by allowing to close suggestions list with keys ARROW_LEFT or ARROW_RIGHT
1819
- Improve Text Editor auto-suggestions by using: selected text, text at left or at right of cursor
1920

pytest.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[pytest]
2-
addopts = -p no:warnings
2+
addopts = -p no:warnings --order-group-scope=module
33

requirements-dev.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ github3.py
55
memory-profiler
66
pylint
77
pytest
8+
coverage
89
pytest-cov
10+
pytest-order
911
# To make a relase you need asciidoc3 (a2x3)
1012
# asciidoc3
1113
# Include also normal project requirements.

src/robotide/application/CHANGELOG.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" xml:lang="en"/><title>Changelog</title><link rel="stylesheet" type="text/css" href="docbook-xsl.css" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /></head><body><div xml:lang="en" class="article" lang="en"><div class="titlepage"><div><div><h2 class="title"><a id="idm45173585623536"></a>Changelog</h2></div></div><hr /></div><p>All notable changes to this project will be documented in this file.</p><p>The format is based on <a class="ulink" href="http://keepachangelog.com/en/1.0.0/" target="_top">Keep a Changelog</a>
2+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Changelog</title><link rel="stylesheet" type="text/css" href="docbook-xsl.css" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /></head><body><div xml:lang="en" class="article" lang="en"><div class="titlepage"><div><div><h2 class="title"><a id="id1337"></a>Changelog</h2></div></div><hr /></div><p>All notable changes to this project will be documented in this file.</p><p>The format is based on <a class="ulink" href="http://keepachangelog.com/en/1.0.0/" target="_top">Keep a Changelog</a>
33
and this project adheres to <a class="ulink" href="http://semver.org/spec/v2.0.0.html" target="_top">Semantic Versioning</a>.</p><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_ulink_url_https_github_com_robotframework_ride_unreleased_ulink"></a>1. <a class="ulink" href="https://github.com/robotframework/RIDE" target="_top">Unreleased</a></h2></div></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="_added"></a>1.1. Added</h3></div></div></div><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
44
Added boolean parameter ``filter newlines`` to Grid Editor with default ``True``, to hide or show newlines in cells
55
</li></ul></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="_changed"></a>1.2. Changed</h3></div></div></div><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
6+
Changed ``tasks.py`` to test ``utest/application/test_app_main.py`` isolated from the other tests
7+
</li><li class="listitem">
68
Improve auto-suggestions of keywords in Grid Editor by allowing to close suggestions list with keys ARROW_LEFT or ARROW_RIGHT
79
</li><li class="listitem">
810
Improve Text Editor auto-suggestions by using: selected text, text at left or at right of cursor
@@ -510,4 +512,4 @@
510512
None
511513
</li></ul></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="_fixed_8"></a>11.4. Fixed</h3></div></div></div><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
512514
None
513-
</li></ul></div></div></div></div></body></html>
515+
</li></ul></div></div></div></div></body></html>

src/robotide/editor/kweditor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1096,7 +1096,7 @@ def EndEdit(self, row, col, gridd, *ignored):
10961096
value = temp_value
10971097
if value != self._original_value:
10981098
self._value = value
1099-
# DEBUG: this is not needed wx.CallAfter(self._grid.move_grid_cursor_and_edit)
1099+
wx.CallAfter(self._grid.move_grid_cursor_and_edit)
11001100
return value
11011101
else:
11021102
self._tc.hide()

src/robotide/editor/texteditor.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -948,12 +948,14 @@ def execute_variable_creator(self, list_variable=False, dict_variable=False):
948948
if size == 0:
949949
self.source_editor.SetInsertionPoint(to_)
950950
self.source_editor.InsertText(from_, self._variable_creator_value(symbol))
951+
self.source_editor.SetSelection(from_ + 2, from_ + 2,)
951952
self.source_editor.SetInsertionPoint(from_ + 2)
952953
else:
953954
self.source_editor.DeleteRange(from_, size)
954955
self.source_editor.SetInsertionPoint(from_)
955956
self.source_editor.ReplaceSelection(self._variable_creator_value(symbol, text))
956-
self.source_editor.SetSelection(from_ + 2, from_ + size + 2)
957+
self.source_editor.SetSelection(from_ + size + 2, from_ + size + 2)
958+
self.source_editor.SetInsertionPoint(from_ + size + 2)
957959

958960
@staticmethod
959961
def _variable_creator_value(symbol, value=''):

tasks.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,9 @@ def test(ctx, test_filter=''):
185185
additional_args = []
186186
if test_filter:
187187
additional_args.append(test_filter)
188+
result = pytestrun(args=["utest/application/test_app_main.py"] + additional_args)
189+
assert result == 0
190+
additional_args.append("--ignore=utest/application/test_app_main.py")
188191
result = pytestrun(args=[TEST_DIR] + additional_args)
189192
assert result == 0
190193

@@ -385,17 +388,9 @@ def sonar(ctx, test_filter=''):
385388
_set_development_path()
386389

387390
try:
391+
test_ci(ctx, test_filter)
388392
import subprocess
389-
c = subprocess.Popen(["coverage", "run", "-m", "pytest", "--cov-config=.coveragerc", "-k test_", "-v",
390-
TEST_DIR])
391-
c.communicate(b'')
392-
r = subprocess.Popen(["coverage", "report"])
393-
r.communicate(b'')
394-
x = subprocess.Popen(["coverage", "xml"])
395-
x.communicate(b'')
396-
h = subprocess.Popen(["coverage", "html"])
397-
h.communicate(b'')
398-
s = subprocess.Popen(["sonar-scanner", "-D", "sonar.projectVersion='v"+VERSION+"'"])
393+
s = subprocess.Popen(["sonar-scanner", "-D", "sonar.projectVersion='"+VERSION+"'"])
399394
s.communicate(b'')
400395
finally:
401396
""" Nothing to do """
@@ -412,8 +407,12 @@ def test_ci(ctx, test_filter=''):
412407

413408
try:
414409
import subprocess
415-
c = subprocess.Popen(["coverage", "run", "-m", "pytest", "--cov-config=.coveragerc", "-k test_", "-v",
416-
TEST_DIR])
410+
411+
a = subprocess.Popen(["coverage", "run", "-a", "-m", "pytest", "--cov-config=.coveragerc", "-k test_", "-v", "utest/application/test_app_main.py"])
412+
a.communicate(b'')
413+
b = subprocess.Popen(["coverage", "run", "-a", "-m", "pytest", "--ignore=utest/application/test_app_main.py", "--cov-config=.coveragerc", "-k test_", "-v", TEST_DIR])
414+
b.communicate(b'')
415+
c = subprocess.Popen(["coverage", "combine"])
417416
c.communicate(b'')
418417
r = subprocess.Popen(["coverage", "report"])
419418
r.communicate(b'')

tools/mkhtml.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
sys.path.insert(0, '../src')
1212
from robotide.version import VERSION
1313
from robotide.application.releasenotes import RELEASE_NOTES
14-
source_path = "../doc/releasenotes/ride-"+".".join([str(x) for x in VERSION.split('.')]).replace('v','')+".rst"
14+
source_path = "../doc/releasenotes/ride-"+".".join([str(x) for x in VERSION.split('.')]).replace('v2','2')+".rst"
1515

1616
# Reverted flow: First edit ../src/robotide/application/releasenotes.py and then generate ride-VERSION.rst
1717
if exists(source_path):
@@ -45,9 +45,9 @@
4545
# Remove ToC
4646
import re
4747
# <div class="toc"> <p>All notable
48-
with open(destination_path, "r") as sources:
48+
with open(destination_path, "r", encoding="utf-8") as sources:
4949
lines = sources.readlines()
50-
with open(destination_path, "w") as sources:
50+
with open(destination_path, "w", encoding="utf-8") as sources:
5151
for line in lines:
5252
sources.write(re.sub(r"<div class=\"toc\">.*<p>All notable", "<p>All notable", line))
5353

utest/application/test_app_main.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14+
import sys
1415
import unittest
1516
import pytest
1617
from pytest import MonkeyPatch
@@ -34,14 +35,19 @@ class TestWxImport(unittest.TestCase):
3435
def tearDown(self):
3536
builtins.__import__ = real_import
3637

38+
@pytest.mark.order(1)
3739
def test_missing_wx(self): # This test passed in PyCharm but not when run in command line
3840
with MonkeyPatch().context() as m:
3941
with pytest.raises((ModuleNotFoundError, SystemExit)): # (ImportError, ModuleNotFoundError, SystemExit)):
42+
sys.modules.pop('wx.lib.inspection', None)
4043
builtins.__import__ = myimport
4144
import robotide
4245
print(dir(robotide))
4346

4447

48+
builtins.__import__ = real_import
49+
50+
4551
class TestMain(unittest.TestCase):
4652

4753
def tearDown(self):

0 commit comments

Comments
 (0)