Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Selenium2Library/keywords/_runonfailure.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def _run_on_failure(self):
self._running_on_failure_routine = True
try:
BUILTIN.run_keyword(self._run_on_failure_keyword)
except Exception, err:
except Exception as err:
self._run_on_failure_error(err)
finally:
self._running_on_failure_routine = False
Expand Down
2 changes: 1 addition & 1 deletion src/Selenium2Library/keywords/_tableelement.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def table_cell_should_contain(self, table_locator, row, column, expected, loglev
% (table_locator, row, column, expected))
try:
content = self.get_table_cell(table_locator, row, column, loglevel='NONE')
except AssertionError, err:
except AssertionError as err:
self._info(err)
self.log_source(loglevel)
raise AssertionError(message)
Expand Down
4 changes: 2 additions & 2 deletions src/Selenium2Library/keywords/keywordgroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def _run_on_failure_decorator(method, *args, **kwargs):
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.
try:
return method(*args, **kwargs)
except Exception, err:
except Exception as err:
if hasattr(self, '_run_on_failure') and not self._has_run_on_failure:
# If we're in an inner keyword, track the fact that we've already run on failure once
self._has_run_on_failure = True
Expand All @@ -28,7 +28,7 @@ def _run_on_failure_decorator(method, *args, **kwargs):
class KeywordGroupMetaClass(type):
def __new__(cls, clsname, bases, dict):
if decorator:
for name, method in dict.items():
for name, method in list(dict.items()):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

list isn't needed here.

if not name.startswith('_') and inspect.isroutine(method):
dict[name] = decorator(_run_on_failure_decorator, method)
return type.__new__(cls, clsname, bases, dict)
Expand Down
6 changes: 2 additions & 4 deletions src/Selenium2Library/locators/elementfinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def __init__(self):
'default': self._find_by_default
}
self._strategies = NormalizedDict(initial=strategies, caseless=True, spaceless=True)
self._default_strategies = strategies.keys()
self._default_strategies = list(strategies.keys())

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.keys() isn't needed here.


def find(self, browser, locator, tag=None):
assert browser is not None
Expand Down Expand Up @@ -190,9 +190,7 @@ def _element_matches(self, element, tag, constraints):
def _filter_elements(self, elements, tag, constraints):
elements = self._normalize_result(elements)
if tag is None: return elements
return filter(
lambda element: self._element_matches(element, tag, constraints),
elements)
return [element for element in elements if self._element_matches(element, tag, constraints)]

def _get_attrs_with_url(self, key_attrs, criteria, browser):
attrs = []
Expand Down
4 changes: 2 additions & 2 deletions test/lib/mockito/invocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ def matches(self, invocation):
return False
if len(self.named_params) != len(invocation.named_params):
return False
if self.named_params.keys() != invocation.named_params.keys():
if list(self.named_params.keys()) != list(invocation.named_params.keys()):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.keys() isn't needed here.

return False

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

for x, p1 in self.named_params.iteritems():
for x, p1 in self.named_params.items():
if not self.compare(p1, invocation.named_params[x]):
return False

Expand Down
2 changes: 1 addition & 1 deletion test/lib/mockito/mock_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def mock_for(self, cls):
return self.mocks.get(cls, None)

def unstub_all(self):
for mock in self.mocks.itervalues():
for mock in self.mocks.values():
mock.unstub()
self.mocks.clear()

Expand Down
2 changes: 1 addition & 1 deletion test/lib/mockito/mockito.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ArgumentError(Exception):
pass

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

def _invalid_argument(value):
return (value is not None and value < 1) or value == 0
Expand Down
6 changes: 3 additions & 3 deletions test/resources/statuschecker.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,14 @@ def _get_log_message(self, msg_str):
import os

if not 2 <= len(sys.argv) <= 3 or '--help' in sys.argv:
print __doc__
print(__doc__)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whole statuschecker.py should actually be removed in favor of https://github.com/robotframework/statuschecker.

sys.exit(1)
infile = sys.argv[1]
outfile = sys.argv[2] if len(sys.argv) == 3 else None
print "Checking %s" % os.path.abspath(infile)
print("Checking %s" % os.path.abspath(infile))
rc = process_output(infile, outfile)
if outfile:
print "Output: %s" % os.path.abspath(outfile)
print("Output: %s" % os.path.abspath(outfile))
if rc > 255:
rc = 255
sys.exit(rc)
2 changes: 1 addition & 1 deletion test/resources/testserver/testserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def start_server(port=7000):
if __name__ == '__main__':
import sys
if len(sys.argv) != 2 or sys.argv[1] not in [ 'start', 'stop' ]:
print 'usage: %s start|stop' % sys.argv[0]
print('usage: %s start|stop' % sys.argv[0])
sys.exit(1)
if sys.argv[1] == 'start':
start_server()
Expand Down
26 changes: 13 additions & 13 deletions test/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,29 +53,29 @@ def execute_tests(runner, args):
if not os.path.exists(env.RESULTS_DIR):
os.mkdir(env.RESULTS_DIR)
command = [runner] + [arg % ARG_VALUES for arg in ROBOT_ARGS] + args + [env.ACCEPTANCE_TEST_DIR]
print ''
print 'Starting test execution with command:\n' + ' '.join(command)
print('')
print('Starting test execution with command:\n' + ' '.join(command))
syslog = os.path.join(env.RESULTS_DIR, 'syslog.txt')
call(command, shell=os.sep=='\\', env=dict(os.environ, ROBOT_SYSLOG_FILE=syslog))

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

def process_output(args):
print
print()
if _has_robot_27():
call(['python', os.path.join(env.RESOURCES_DIR, 'statuschecker.py'),
os.path.join(env.RESULTS_DIR, 'output.xml')])
rebot = 'rebot' if os.sep == '/' else 'rebot.bat'
rebot_cmd = [rebot] + [ arg % ARG_VALUES for arg in REBOT_ARGS ] + args + \
[os.path.join(ARG_VALUES['outdir'], 'output.xml') ]
print ''
print 'Starting output processing with command:\n' + ' '.join(rebot_cmd)
print('')
print('Starting output processing with command:\n' + ' '.join(rebot_cmd))
rc = call(rebot_cmd, env=os.environ)
if rc == 0:
print 'All critical tests passed'
print('All critical tests passed')
else:
print '%d critical test%s failed' % (rc, 's' if rc != 1 else '')
print('%d critical test%s failed' % (rc, 's' if rc != 1 else ''))
return rc

def _has_robot_27():
Expand All @@ -89,18 +89,18 @@ def _exit(rc):
sys.exit(rc)

def _help():
print 'Usage: python run_tests.py python|jython browser [options]'
print
print 'See README.txt for details.'
print('Usage: python run_tests.py python|jython browser [options]')
print()
print('See README.txt for details.')
return 255

def _run_unit_tests():
print 'Running unit tests'
print('Running unit tests')
failures = run_unit_tests()
if failures != 0:
print '\n%d unit tests failed - not running acceptance tests!' % failures
print('\n%d unit tests failed - not running acceptance tests!' % failures)
else:
print 'All unit tests passed'
print('All unit tests passed')
return failures


Expand Down
4 changes: 2 additions & 2 deletions test/run_unit_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ def run_unit_tests(modules_to_run=[]):
bad_modules_to_run = [module_to_run for module_to_run in modules_to_run
if module_to_run not in test_module_names]
if bad_modules_to_run:
print "Specified test module%s not exist: %s" % (
print("Specified test module%s not exist: %s" % (
' does' if len(bad_modules_to_run) == 1 else 's do',
', '.join(bad_modules_to_run))
', '.join(bad_modules_to_run)))
return -1

tests = [unittest.defaultTestLoader.loadTestsFromModule(test_module)
Expand Down
2 changes: 1 addition & 1 deletion test/unit/keywords/test_browsermanagement.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def test_bad_browser_name(self):
try:
bm._make_browser("fireox")
self.fail("Exception not raised")
except ValueError, e:
except ValueError as e:
self.assertEquals("fireox is not a supported browser.", e.message)

def test_create_webdriver(self):
Expand Down