Skip to content

Commit f5229cf

Browse files
Eino Mäkitaloaaltat
Eino Mäkitalo
authored andcommitted
Print fix (robotframework#626)
* 2to3.py runned for print & except * 2to3.py runned for except * 2to3.py -f dict
1 parent 9b6b853 commit f5229cf

File tree

12 files changed

+30
-32
lines changed

12 files changed

+30
-32
lines changed

src/Selenium2Library/keywords/_runonfailure.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def _run_on_failure(self):
5757
self._running_on_failure_routine = True
5858
try:
5959
BUILTIN.run_keyword(self._run_on_failure_keyword)
60-
except Exception, err:
60+
except Exception as err:
6161
self._run_on_failure_error(err)
6262
finally:
6363
self._running_on_failure_routine = False

src/Selenium2Library/keywords/_tableelement.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def table_cell_should_contain(self, table_locator, row, column, expected, loglev
6464
% (table_locator, row, column, expected))
6565
try:
6666
content = self.get_table_cell(table_locator, row, column, loglevel='NONE')
67-
except AssertionError, err:
67+
except AssertionError as err:
6868
self._info(err)
6969
self.log_source(loglevel)
7070
raise AssertionError(message)

src/Selenium2Library/keywords/keywordgroup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def _run_on_failure_decorator(method, *args, **kwargs):
1313
self._already_in_keyword = True # Set a flag on the instance so that as we call keywords inside this call and this gets run again, we know we're at least one level in.
1414
try:
1515
return method(*args, **kwargs)
16-
except Exception, err:
16+
except Exception as err:
1717
if hasattr(self, '_run_on_failure') and not self._has_run_on_failure:
1818
# If we're in an inner keyword, track the fact that we've already run on failure once
1919
self._has_run_on_failure = True
@@ -28,7 +28,7 @@ def _run_on_failure_decorator(method, *args, **kwargs):
2828
class KeywordGroupMetaClass(type):
2929
def __new__(cls, clsname, bases, dict):
3030
if decorator:
31-
for name, method in dict.items():
31+
for name, method in list(dict.items()):
3232
if not name.startswith('_') and inspect.isroutine(method):
3333
dict[name] = decorator(_run_on_failure_decorator, method)
3434
return type.__new__(cls, clsname, bases, dict)

src/Selenium2Library/locators/elementfinder.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def __init__(self):
2222
'default': self._find_by_default
2323
}
2424
self._strategies = NormalizedDict(initial=strategies, caseless=True, spaceless=True)
25-
self._default_strategies = strategies.keys()
25+
self._default_strategies = list(strategies.keys())
2626

2727
def find(self, browser, locator, tag=None):
2828
assert browser is not None
@@ -190,9 +190,7 @@ def _element_matches(self, element, tag, constraints):
190190
def _filter_elements(self, elements, tag, constraints):
191191
elements = self._normalize_result(elements)
192192
if tag is None: return elements
193-
return filter(
194-
lambda element: self._element_matches(element, tag, constraints),
195-
elements)
193+
return [element for element in elements if self._element_matches(element, tag, constraints)]
196194

197195
def _get_attrs_with_url(self, key_attrs, criteria, browser):
198196
attrs = []

test/lib/mockito/invocation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ def matches(self, invocation):
4747
return False
4848
if len(self.named_params) != len(invocation.named_params):
4949
return False
50-
if self.named_params.keys() != invocation.named_params.keys():
50+
if list(self.named_params.keys()) != list(invocation.named_params.keys()):
5151
return False
5252

5353
for x, p1 in enumerate(self.params):
5454
if not self.compare(p1, invocation.params[x]):
5555
return False
5656

57-
for x, p1 in self.named_params.iteritems():
57+
for x, p1 in self.named_params.items():
5858
if not self.compare(p1, invocation.named_params[x]):
5959
return False
6060

test/lib/mockito/mock_registry.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def mock_for(self, cls):
1212
return self.mocks.get(cls, None)
1313

1414
def unstub_all(self):
15-
for mock in self.mocks.itervalues():
15+
for mock in self.mocks.values():
1616
mock.unstub()
1717
self.mocks.clear()
1818

test/lib/mockito/mockito.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class ArgumentError(Exception):
1515
pass
1616

1717
def _multiple_arguments_in_use(*args):
18-
return len(filter(lambda x: x, args)) > 1
18+
return len([x for x in args if x]) > 1
1919

2020
def _invalid_argument(value):
2121
return (value is not None and value < 1) or value == 0

test/resources/statuschecker.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,14 +177,14 @@ def _get_log_message(self, msg_str):
177177
import os
178178

179179
if not 2 <= len(sys.argv) <= 3 or '--help' in sys.argv:
180-
print __doc__
180+
print(__doc__)
181181
sys.exit(1)
182182
infile = sys.argv[1]
183183
outfile = sys.argv[2] if len(sys.argv) == 3 else None
184-
print "Checking %s" % os.path.abspath(infile)
184+
print("Checking %s" % os.path.abspath(infile))
185185
rc = process_output(infile, outfile)
186186
if outfile:
187-
print "Output: %s" % os.path.abspath(outfile)
187+
print("Output: %s" % os.path.abspath(outfile))
188188
if rc > 255:
189189
rc = 255
190190
sys.exit(rc)

test/resources/testserver/testserver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def start_server(port=7000):
9494
if __name__ == '__main__':
9595
import sys
9696
if len(sys.argv) != 2 or sys.argv[1] not in [ 'start', 'stop' ]:
97-
print 'usage: %s start|stop' % sys.argv[0]
97+
print('usage: %s start|stop' % sys.argv[0])
9898
sys.exit(1)
9999
if sys.argv[1] == 'start':
100100
start_server()

test/run_tests.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,29 +53,29 @@ def execute_tests(runner, args):
5353
if not os.path.exists(env.RESULTS_DIR):
5454
os.mkdir(env.RESULTS_DIR)
5555
command = [runner] + [arg % ARG_VALUES for arg in ROBOT_ARGS] + args + [env.ACCEPTANCE_TEST_DIR]
56-
print ''
57-
print 'Starting test execution with command:\n' + ' '.join(command)
56+
print('')
57+
print('Starting test execution with command:\n' + ' '.join(command))
5858
syslog = os.path.join(env.RESULTS_DIR, 'syslog.txt')
5959
call(command, shell=os.sep=='\\', env=dict(os.environ, ROBOT_SYSLOG_FILE=syslog))
6060

6161
def stop_http_server():
6262
call(['python', env.HTTP_SERVER_FILE, 'stop'])
6363

6464
def process_output(args):
65-
print
65+
print()
6666
if _has_robot_27():
6767
call(['python', os.path.join(env.RESOURCES_DIR, 'statuschecker.py'),
6868
os.path.join(env.RESULTS_DIR, 'output.xml')])
6969
rebot = 'rebot' if os.sep == '/' else 'rebot.bat'
7070
rebot_cmd = [rebot] + [ arg % ARG_VALUES for arg in REBOT_ARGS ] + args + \
7171
[os.path.join(ARG_VALUES['outdir'], 'output.xml') ]
72-
print ''
73-
print 'Starting output processing with command:\n' + ' '.join(rebot_cmd)
72+
print('')
73+
print('Starting output processing with command:\n' + ' '.join(rebot_cmd))
7474
rc = call(rebot_cmd, env=os.environ)
7575
if rc == 0:
76-
print 'All critical tests passed'
76+
print('All critical tests passed')
7777
else:
78-
print '%d critical test%s failed' % (rc, 's' if rc != 1 else '')
78+
print('%d critical test%s failed' % (rc, 's' if rc != 1 else ''))
7979
return rc
8080

8181
def _has_robot_27():
@@ -89,18 +89,18 @@ def _exit(rc):
8989
sys.exit(rc)
9090

9191
def _help():
92-
print 'Usage: python run_tests.py python|jython browser [options]'
93-
print
94-
print 'See README.txt for details.'
92+
print('Usage: python run_tests.py python|jython browser [options]')
93+
print()
94+
print('See README.txt for details.')
9595
return 255
9696

9797
def _run_unit_tests():
98-
print 'Running unit tests'
98+
print('Running unit tests')
9999
failures = run_unit_tests()
100100
if failures != 0:
101-
print '\n%d unit tests failed - not running acceptance tests!' % failures
101+
print('\n%d unit tests failed - not running acceptance tests!' % failures)
102102
else:
103-
print 'All unit tests passed'
103+
print('All unit tests passed')
104104
return failures
105105

106106

test/run_unit_tests.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ def run_unit_tests(modules_to_run=[]):
1010
bad_modules_to_run = [module_to_run for module_to_run in modules_to_run
1111
if module_to_run not in test_module_names]
1212
if bad_modules_to_run:
13-
print "Specified test module%s not exist: %s" % (
13+
print("Specified test module%s not exist: %s" % (
1414
' does' if len(bad_modules_to_run) == 1 else 's do',
15-
', '.join(bad_modules_to_run))
15+
', '.join(bad_modules_to_run)))
1616
return -1
1717

1818
tests = [unittest.defaultTestLoader.loadTestsFromModule(test_module)

test/unit/keywords/test_browsermanagement.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def test_bad_browser_name(self):
9696
try:
9797
bm._make_browser("fireox")
9898
self.fail("Exception not raised")
99-
except ValueError, e:
99+
except ValueError as e:
100100
self.assertEquals("fireox is not a supported browser.", e.message)
101101

102102
def test_create_webdriver(self):

0 commit comments

Comments
 (0)