1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/e4e1f70bc2d1/
Changeset: e4e1f70bc2d1
User: jmchilton
Date: 2014-11-26 01:57:56+00:00
Summary: PEP-8 fixes for test.base.asserts.
Some of the first Python code I ever wrote - and one can tell :).
Affected #: 4 files
diff -r bfa13d090966889c74512497bfcaafb732c08a41 -r e4e1f70bc2d1a84219038b7e58b933a94b424da7 test/base/asserts/__init__.py
--- a/test/base/asserts/__init__.py
+++ b/test/base/asserts/__init__.py
@@ -8,7 +8,7 @@
# Code for loading modules containing assertion checking functions, to
# create a new module of assertion functions, create the needed python
# source file "test/base/asserts/<MODULE_NAME>.py" and add
-# <MODULE_NAME> to the list of assertion module names defined above.
+# <MODULE_NAME> to the list of assertion module names defined above.
assertion_modules = []
for assertion_module_name in assertion_module_names:
full_assertion_module_name = 'base.asserts.' + assertion_module_name
@@ -19,7 +19,8 @@
assertion_module = sys.modules[full_assertion_module_name]
assertion_modules.append(assertion_module)
except Exception, e:
- log.exception( 'Failed to load assertion module: %s %s' % (assertion_module_name, str(e)))
+ log.exception('Failed to load assertion module: %s %s' % (assertion_module_name, str(e)))
+
def verify_assertions(data, assertion_description_list):
""" This function takes a list of assertions and a string to check
@@ -27,6 +28,7 @@
for assertion_description in assertion_description_list:
verify_assertion(data, assertion_description)
+
def verify_assertion(data, assertion_description):
tag = assertion_description["tag"]
assert_function_name = "assert_" + tag
@@ -73,4 +75,3 @@
# TODO: Verify all needed function arguments are specified.
assert_function(**args)
-
diff -r bfa13d090966889c74512497bfcaafb732c08a41 -r e4e1f70bc2d1a84219038b7e58b933a94b424da7 test/base/asserts/tabular.py
--- a/test/base/asserts/tabular.py
+++ b/test/base/asserts/tabular.py
@@ -1,13 +1,15 @@
import re
+
def get_first_line(output):
- match = re.search("^(.*)$", output, flags = re.MULTILINE)
+ match = re.search("^(.*)$", output, flags=re.MULTILINE)
if match is None:
return None
else:
return match.group(1)
-def assert_has_n_columns(output, n, sep = '\t'):
+
+def assert_has_n_columns(output, n, sep='\t'):
""" Asserts the tabular output contains n columns. The optional
sep argument specifies the column seperator used to determine the
number of columns."""
diff -r bfa13d090966889c74512497bfcaafb732c08a41 -r e4e1f70bc2d1a84219038b7e58b933a94b424da7 test/base/asserts/text.py
--- a/test/base/asserts/text.py
+++ b/test/base/asserts/text.py
@@ -1,30 +1,34 @@
import re
+
def assert_has_text(output, text):
""" Asserts specified output contains the substring specified by
the argument text."""
assert output.find(text) >= 0, "Output file did not contain expected text '%s' (ouptut '%s')" % (text, output)
-
+
+
def assert_not_has_text(output, text):
""" Asserts specified output does not contain the substring
specified the argument text."""
assert output.find(text) < 0, "Output file contains unexpected text '%s'" % text
+
def assert_has_line(output, line):
""" Asserts the specified output contains the line specified the
argument line."""
- match = re.search("^%s$" % re.escape(line), output, flags = re.MULTILINE)
- assert match != None, "No line of output file was '%s' (output was '%s') " % (line, output)
+ match = re.search("^%s$" % re.escape(line), output, flags=re.MULTILINE)
+ assert match is not None, "No line of output file was '%s' (output was '%s') " % (line, output)
+
def assert_has_text_matching(output, expression):
""" Asserts the specified output contains text matching the
regular expression specified by the argument expression."""
match = re.search(expression, output)
- assert match != None, "No text matching expression '%s' was found in output file." % expression
+ assert match is not None, "No text matching expression '%s' was found in output file." % expression
+
def assert_has_line_matching(output, expression):
""" Asserts the specified output contains a line matching the
regular expression specified by the argument expression."""
- match = re.search("^%s$" % expression, output, flags = re.MULTILINE)
- assert match != None, "No line matching expression '%s' was found in output file." % expression
-
+ match = re.search("^%s$" % expression, output, flags=re.MULTILINE)
+ assert match is not None, "No line matching expression '%s' was found in output file." % expression
diff -r bfa13d090966889c74512497bfcaafb732c08a41 -r e4e1f70bc2d1a84219038b7e58b933a94b424da7 test/base/asserts/xml.py
--- a/test/base/asserts/xml.py
+++ b/test/base/asserts/xml.py
@@ -1,77 +1,88 @@
import elementtree.ElementTree
import re
+
# Helper functions used to work with XML output.
def to_xml(output):
- return elementtree.ElementTree.fromstring(output)
+ return elementtree.ElementTree.fromstring(output)
+
def xml_find_text(output, path):
- xml = to_xml(output)
- text = xml.findtext(path)
- return text
+ xml = to_xml(output)
+ text = xml.findtext(path)
+ return text
+
def xml_find(output, path):
- xml = to_xml(output)
- return xml.find(path)
+ xml = to_xml(output)
+ return xml.find(path)
+
def assert_is_valid_xml(output):
- """ Simple assertion that just verifies the specified output
- is valid XML."""
- try:
- to_xml(output)
- except Exception, e:
- # TODO: Narrow caught exception to just parsing failure
- raise AssertionError("Expected valid XML, but could not parse output. %s" % str(e))
+ """ Simple assertion that just verifies the specified output
+ is valid XML."""
+ try:
+ to_xml(output)
+ except Exception, e:
+ # TODO: Narrow caught exception to just parsing failure
+ raise AssertionError("Expected valid XML, but could not parse output. %s" % str(e))
+
def assert_has_element_with_path(output, path):
- """ Asserts the specified output has at least one XML element with a
- path matching the specified path argument. Valid paths are the
- simplified subsets of XPath implemented by elementtree (currently
- Galaxy makes use of elementtree 1.2). See
- http://effbot.org/zone/element-xpath.htm for more information."""
- if xml_find(output, path) is None:
- errmsg = "Expected to find XML element matching expression %s, not such match was found." % path
- raise AssertionError(errmsg)
+ """ Asserts the specified output has at least one XML element with a
+ path matching the specified path argument. Valid paths are the
+ simplified subsets of XPath implemented by elementtree (currently
+ Galaxy makes use of elementtree 1.2). See
+ http://effbot.org/zone/element-xpath.htm for more information."""
+ if xml_find(output, path) is None:
+ errmsg = "Expected to find XML element matching expression %s, not such match was found." % path
+ raise AssertionError(errmsg)
+
def assert_has_n_elements_with_path(output, path, n):
- """ Asserts the specified output has exactly n elements matching the
- path specified."""
- xml = to_xml(output)
- n = int(n)
- num_elements = len(xml.findall(path))
- if num_elements != n:
- errmsg = "Expected to find %d elements with path %s, but %d were found." % (n, path, num_elements)
- raise AssertionError(errmsg)
+ """ Asserts the specified output has exactly n elements matching the
+ path specified."""
+ xml = to_xml(output)
+ n = int(n)
+ num_elements = len(xml.findall(path))
+ if num_elements != n:
+ errmsg = "Expected to find %d elements with path %s, but %d were found." % (n, path, num_elements)
+ raise AssertionError(errmsg)
+
def assert_element_text_matches(output, path, expression):
- """ Asserts the text of the first element matching the specified
- path matches the specified regular expression."""
- text = xml_find_text(output, path)
- if re.match(expression, text) is None:
- errmsg = "Expected element with path '%s' to contain text matching '%s', instead text '%s' was found." % (path, text, actual_text)
- raise AssertionError(errmsg)
+ """ Asserts the text of the first element matching the specified
+ path matches the specified regular expression."""
+ text = xml_find_text(output, path)
+ if re.match(expression, text) is None:
+ errmsg = "Expected element with path '%s' to contain text matching '%s', instead text '%s' was found." % (path, expression, text)
+ raise AssertionError(errmsg)
+
def assert_element_text_is(output, path, text):
- """ Asserts the text of the first element matching the specified
- path matches exactly the specified text. """
- assert_element_text_matches(output, path, re.escape(text))
+ """ Asserts the text of the first element matching the specified
+ path matches exactly the specified text. """
+ assert_element_text_matches(output, path, re.escape(text))
+
def assert_attribute_matches(output, path, attribute, expression):
- """ Asserts the specified attribute of the first element matching
- the specified path matches the specified regular expression."""
- xml = xml_find(output, path)
- attribute_value = xml.attrib[attribute]
- if re.match(expression, attribute_value) is None:
- errmsg = "Expected attribute '%s' on element with path '%s' to match '%s', instead attribute value was '%s'." % (attribute, path, expression, attribute_value)
- raise AssertionError(errmsg)
+ """ Asserts the specified attribute of the first element matching
+ the specified path matches the specified regular expression."""
+ xml = xml_find(output, path)
+ attribute_value = xml.attrib[attribute]
+ if re.match(expression, attribute_value) is None:
+ errmsg = "Expected attribute '%s' on element with path '%s' to match '%s', instead attribute value was '%s'." % (attribute, path, expression, attribute_value)
+ raise AssertionError(errmsg)
+
def assert_attribute_is(output, path, attribute, text):
- """ Asserts the specified attribute of the first element matching
- the specified path matches exactly the specified text."""
- assert_attribute_matches(output, path, attribute, re.escape(text))
+ """ Asserts the specified attribute of the first element matching
+ the specified path matches exactly the specified text."""
+ assert_attribute_matches(output, path, attribute, re.escape(text))
+
def assert_element_text(output, path, verify_assertions_function, children):
- """ Recursively checks the specified assertions against the text of
- the first element matching the specified path."""
- text = xml_find_text(output, path)
- verify_assertions_function(text, children)
+ """ Recursively checks the specified assertions against the text of
+ the first element matching the specified path."""
+ text = xml_find_text(output, path)
+ verify_assertions_function(text, children)
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/ce8a617dcdb1/
Changeset: ce8a617dcdb1
User: dannon
Date: 2014-11-25 19:35:25+00:00
Summary: Merge next stable.
Affected #: 2 files
diff -r 720b9c3936980d5af25df714c5c65e5d4793327c -r ce8a617dcdb199e97e7d4249f548e78a4530d18a lib/galaxy/web/framework/helpers/__init__.py
--- a/lib/galaxy/web/framework/helpers/__init__.py
+++ b/lib/galaxy/web/framework/helpers/__init__.py
@@ -3,13 +3,13 @@
"""
import time
-from cgi import escape
from datetime import datetime, timedelta
from galaxy import eggs
from galaxy.util import hash_util
from galaxy.util.json import safe_dumps as dumps
eggs.require( "MarkupSafe" ) #required by WebHelpers
eggs.require( "WebHelpers" )
+from markupsafe import escape
from webhelpers import date
from webhelpers.html.tags import stylesheet_link, javascript_link
diff -r 720b9c3936980d5af25df714c5c65e5d4793327c -r ce8a617dcdb199e97e7d4249f548e78a4530d18a lib/galaxy/webapps/galaxy/controllers/tool_runner.py
--- a/lib/galaxy/webapps/galaxy/controllers/tool_runner.py
+++ b/lib/galaxy/webapps/galaxy/controllers/tool_runner.py
@@ -15,8 +15,8 @@
from galaxy.tools.parameters.basic import UnvalidatedValue
from galaxy.util.bunch import Bunch
from galaxy.util.hash_util import is_hashable
-from galaxy.web import error
-from galaxy.web import url_for
+from galaxy.web import error, url_for
+from galaxy.web.framework.helpers import escape
from galaxy.web.base.controller import BaseUIController
import tool_shed.util.shed_util_common as suc
@@ -57,7 +57,7 @@
return trans.response.send_redirect( url_for( controller="root", action="welcome" ) )
# When the tool form is initially loaded, the received kwd will not include a 'refresh'
# entry (which only is included when another option is selected in the tool_version_select_field),
- # so the default selected option should be the most recent version of the tool. The following
+ # so the default selected option should be the most recent version of the tool. The following
# check will mae sure this occurs.
refreshed_on_change = kwd.get( 'refresh', False )
tool_version_select_field, tools, tool = self.__get_tool_components( tool_id,
@@ -69,7 +69,7 @@
log.error( "index called with tool id '%s' but no such tool exists", tool_id )
trans.log_event( "Tool id '%s' does not exist" % tool_id )
trans.response.status = 404
- return "Tool '%s' does not exist, kwd=%s " % ( tool_id, kwd )
+ return trans.show_error_message("Tool '%s' does not exist." % ( escape(tool_id) ))
if tool.require_login and not trans.user:
message = "You must be logged in to use this tool."
status = "info"
@@ -291,7 +291,7 @@
log.error( "data_source_redirect called with tool id '%s' but no such tool exists", tool_id )
trans.log_event( "Tool id '%s' does not exist" % tool_id )
trans.response.status = 404
- return "Tool '%s' does not exist, kwd=%s " % ( tool_id, kwd )
+ return trans.show_error_message("Tool '%s' does not exist." % ( escape(tool_id) ))
if isinstance( tool, DataSourceTool ):
link = url_for( tool.action, **tool.get_static_param_values( trans ) )
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.