Skip to content

Commit 2230356

Browse files
Improve code (#2592)
1 parent e345c3e commit 2230356

File tree

8 files changed

+83
-82
lines changed

8 files changed

+83
-82
lines changed

README.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Likewise, the current version of wxPython, is 4.2.0, but RIDE is known to work w
3232

3333
`pip install -U robotframework-ride`
3434

35-
Install current development version (**2.0.5**) with:
35+
Install current development version (**2.0.6dev#**) with:
3636

3737
`pip install -U https://github.com/robotframework/RIDE/archive/master.zip`
3838

pytest.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[pytest]
2+
addopts = -p no:warnings
3+

src/robotide/__init__.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
from string import Template
3636

3737
errorMessageTemplate = Template("""$reason
38-
RIDE depends on wx (wxPython). Historically, the last supported version was 2.8.12.1 with unicode support.\
39-
At the time of this release the current wxPython version is 4.0.7.post2.\
38+
RIDE depends on wx (wxPython). Known versions for Python3 are: 4.0.7.post2, 4.1.1 and 4.2.0.\
39+
At the time of this release the current wxPython version is 4.2.0.\
4040
You can install with 'pip install wxPython' on most operating systems, or find the \
4141
the download link from https://wxPython.org/""")
4242

@@ -106,13 +106,21 @@ def _run(inpath=None, updatecheck=True, debug_console=False):
106106
def _replace_std_for_win():
107107

108108
class NullStream:
109-
def close(self): pass
109+
def close(self):
110+
""" Override """
111+
pass
110112

111-
def flush(self): pass
113+
def flush(self):
114+
""" Override """
115+
pass
112116

113-
def write(self, line): pass
117+
def write(self, line):
118+
""" Override """
119+
pass
114120

115-
def writelines(self, sequence): pass
121+
def writelines(self, sequence):
122+
""" Override """
123+
pass
116124

117125
if sys.executable.endswith('pythonw.exe'):
118126
# In windows, when launching RIDE with pythonw.exe
@@ -124,12 +132,12 @@ def writelines(self, sequence): pass
124132

125133

126134
def _show_old_wxpython_warning_if_needed(parent=None):
127-
if wx.VERSION <=(4, 0, 4, '', ''):
135+
if wx.VERSION <= (4, 0, 4, '', ''):
128136
title = "Please upgrade your wxPython installation"
129137
message = ("RIDE needs a newer wxPython version. Your current "
130138
"version is %s."
131139
"\n"
132-
"At the time of this release the current wxPython version is 4.0.7.post2. See "
140+
"At the time of this release the current wxPython version is 4.2.0. See "
133141
"https://wxPython.org/ for downloads and instructions."
134142
% wx.VERSION_STRING)
135143
style = wx.ICON_EXCLAMATION
@@ -138,10 +146,6 @@ def _show_old_wxpython_warning_if_needed(parent=None):
138146
parent = wx.Frame(None, size=(0, 0))
139147
sys.stderr.write("{0}\n{1}\n".format(title, message))
140148
dlg = wx.MessageDialog(parent, message=message, caption=title, style=style)
141-
"""
142-
dlg.SetBackgroundColour(Colour(200, 222, 40))
143-
dlg.SetForegroundColour(Colour(7, 0, 70))
144-
"""
145149
dlg.ShowModal()
146150

147151

src/robotide/application/CHANGELOG.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
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"><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" 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>
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">

src/robotide/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414
# limitations under the License.
1515
#
1616
# Automatically generated by `tasks.py`.
17-
VERSION = 'v2.0.6dev2'
17+
VERSION = 'v2.0.6dev3'

utest/controller/base_command_test.py

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
import pathlib
1919
import shutil
2020
import sys
21+
from robotide.publish import PUBLISHER
22+
from robotide.publish.messages import RideItemStepsChanged
2123

2224
# Workaround for relative import in non-module
2325
# see https://stackoverflow.com/questions/16981921/relative-imports-in-python-3
@@ -27,24 +29,20 @@
2729
sys.path.insert(0, os.path.normpath(os.path.join(SCRIPT_DIR, PACKAGE_PARENT)))
2830
SCRIPT_DIR = os.path.dirname(pathlib.Path(__file__).parent)
2931
sys.path.insert(0, SCRIPT_DIR)
30-
31-
from robotide.publish import PUBLISHER
32-
from robotide.publish.messages import RideItemStepsChanged
33-
from controller.controller_creator import _FakeProject, testcase_controller, BASE_DATA
32+
from controller_creator import _FakeProject, testcase_controller, BASE_DATA
3433

3534

3635
class TestCaseCommandTest(unittest.TestCase, _FakeProject):
3736

3837
resource_file_controller_factory = None
3938

4039
def setUp(self):
41-
# self._steps = None
4240
self._data = self._create_data()
4341
self._ctrl = testcase_controller(self, data=self._data)
4442
PUBLISHER.subscribe(self._test_changed, RideItemStepsChanged)
4543
self._orig_number_of_steps = len(self._ctrl.steps)
4644
self._steps = self._ctrl.steps
47-
print(f"\nBase Data")
45+
print("\nBase Data")
4846
for row in self._steps:
4947
print(f"{row.as_list()}")
5048
print(f"DEBUG: base setup self._orig_number_of_steps={self._orig_number_of_steps}")
@@ -61,9 +59,6 @@ def _create_data(self):
6159
def save(self, controller):
6260
self._file_saved = (controller == self._ctrl.datafile_controller)
6361

64-
# def tearDown(self):
65-
# PUBLISHER.unsubscribe(self._test_changed, RideItemStepsChanged)
66-
6762
def _get_macros(self):
6863
return [m for m in self._ctrl._parent]
6964

@@ -73,7 +68,8 @@ def _get_macro_by_name(self, name):
7368
def _data_row(self, line):
7469
return self._data.index(line) - 1
7570

76-
def _data_step_as_list(self, step_data):
71+
@staticmethod
72+
def _data_step_as_list(step_data):
7773
return step_data.split(' ')[:]
7874

7975
def _exec(self, command):
@@ -86,8 +82,6 @@ def _test_changed(self, message):
8682
def _verify_step_unchanged(self, step_data):
8783
row = self._data_row(step_data)
8884
step = self._steps[row].as_list()
89-
# if step and step[0] != '':
90-
# step = [''] + step
9185
step = [''] + step
9286
assert step == self._data_step_as_list(step_data)[:]
9387

@@ -106,7 +100,9 @@ def _verify_row_does_not_exist(self, line):
106100
def _verify_step_is_empty(self, index):
107101
assert self._steps[index].as_list() == []
108102

109-
def _verify_step(self, index, exp_name, exp_args=[], exp_comment=None, kw=True):
103+
def _verify_step(self, index, exp_name, exp_args=None, exp_comment=None, kw=True):
104+
if not exp_args:
105+
exp_args = []
110106
if exp_name == '':
111107
exp_name = []
112108
else:
@@ -125,4 +121,3 @@ def _verify_step_number_change(self, change):
125121

126122
if __name__ == '__main__':
127123
unittest.main()
128-

utest/controller/test_tags.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
import os
1717
import sys
1818
import unittest
19+
from robotide.controller.tags import Tag, DefaultTag, ForcedTag
20+
from robotide.controller.ctrlcommands import ChangeTag
1921

2022
# Workaround for relative import in non-module
2123
# see https://stackoverflow.com/questions/16981921/relative-imports-in-python-3
@@ -29,9 +31,6 @@
2931
except ModuleNotFoundError:
3032
from .controller_creator import testcase_controller
3133

32-
from robotide.controller.tags import Tag, DefaultTag, ForcedTag
33-
from robotide.controller.ctrlcommands import ChangeTag
34-
3534

3635
class Test(unittest.TestCase):
3736

@@ -146,6 +145,6 @@ def _tag_with_name_exists(self, name):
146145
def _tag_with_name_does_not_exists(self, name):
147146
assert not any(t for t in self.tags if t.name == name)
148147

148+
149149
if __name__ == "__main__":
150-
#import sys;sys.argv = ['', 'Test.testName']
151150
unittest.main()

utest/resources/robotdata/datagenerator.py

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -19,57 +19,56 @@
1919
from random import randint
2020
import os
2121

22-
SUITE=\
23-
"""*** Settings ***
24-
Resource resource.robot
25-
26-
*** Test Cases ***
27-
%TESTCASES%
28-
29-
*** Keywords ***
30-
Test Keyword
31-
Log jee
32-
"""
33-
34-
RESOURCE=\
35-
"""*** Variables ***
36-
@{Resource Var} MOI
37-
38-
*** Keywords ***
39-
%KEYWORDS%
40-
"""
41-
42-
KEYWORD_TEMPLATE=\
43-
"""My Keyword %KW_ID%
44-
No Operation"""
45-
46-
TEST_CASE_TEMPLATE=\
47-
"""My Test %TEST_ID%
48-
My Keyword %KW_ID%
49-
Log moi
22+
SUITE = \
23+
"""*** Settings ***
24+
Resource resource.robot
25+
26+
*** Test Cases ***
27+
%TESTCASES%
28+
29+
*** Keywords ***
5030
Test Keyword
51-
Log moi
52-
Test Keyword
53-
Log moi
54-
Test Keyword
55-
Log moi
56-
Test Keyword
57-
Log moi
58-
Test Keyword
59-
My Keyword %KW_ID%
60-
Test Keyword
61-
Log moi
62-
Test Keyword
63-
Log moi
64-
Test Keyword
65-
Log moi"""
31+
Log jee
32+
"""
33+
34+
RESOURCE = \
35+
"""*** Variables ***
36+
@{Resource Var} MOI
37+
38+
*** Keywords ***
39+
%KEYWORDS%
40+
"""
41+
42+
KEYWORD_TEMPLATE = \
43+
"""My Keyword %KW_ID%
44+
No Operation"""
45+
46+
TEST_CASE_TEMPLATE = \
47+
"""My Test %TEST_ID%
48+
My Keyword %KW_ID%
49+
Log moi
50+
Test Keyword
51+
Log moi
52+
Test Keyword
53+
Log moi
54+
Test Keyword
55+
Log moi
56+
Test Keyword
57+
Log moi
58+
Test Keyword
59+
My Keyword %KW_ID%
60+
Test Keyword
61+
Log moi
62+
Test Keyword
63+
Log moi
64+
Test Keyword
65+
Log moi"""
6666

6767

6868
def generate_tests(number_of_tests, number_of_keywords):
6969
mytests = range(number_of_tests)
70-
return '\n'.join(TEST_CASE_TEMPLATE.replace('%TEST_ID%', str(test_id))\
71-
.replace('%KW_ID%', str(randint(0,number_of_keywords-1)))\
72-
for test_id in mytests)
70+
return '\n'.join(TEST_CASE_TEMPLATE.replace('%TEST_ID%', str(test_id))
71+
.replace('%KW_ID%', str(randint(0, number_of_keywords-1))) for test_id in mytests)
7372

7473

7574
def generate_keywords(number_of_keywords):
@@ -97,10 +96,10 @@ def generate(directory, suites, tests, keywords):
9796
return
9897
mysuites = range(suites)
9998
for suite_index in mysuites:
100-
f = open(os.path.join(safepath, 'suite%s.robot' % suite_index), 'w')
99+
f = open(os.path.commonpath(os.path.join(safepath, 'suite%s.robot' % suite_index)), 'w')
101100
f.write(generate_suite(tests, keywords))
102101
f.close()
103-
r = open(os.path.join(safepath, 'resource.robot'), 'w')
102+
r = open(os.path.commonpath(os.path.join(safepath, 'resource.robot')), 'w')
104103
r.write(generate_resource(keywords))
105104
r.close()
106105

@@ -121,6 +120,7 @@ def main(args):
121120
print(opts)
122121
usage()
123122
sys.exit(2)
123+
directory = suites = tests = keywords = None
124124
for opt, arg in opts:
125125
if opt == '-d':
126126
directory = arg
@@ -132,7 +132,7 @@ def main(args):
132132
keywords = int(arg)
133133
generate(directory, suites, tests, keywords)
134134

135+
135136
if __name__ == '__main__':
136137
import sys
137138
main(sys.argv[1:])
138-

0 commit comments

Comments
 (0)