mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-10-28 02:58:18 +08:00
Make str.join()s more efficient
by using generator expressions and tuples instead of lists.
This commit is contained in:
@@ -259,7 +259,7 @@ class Test_LimitedOffsetDataProvider(Test_FilteredDataProvider):
|
||||
(3, 2, result_data[2:3], 1, 1, 1),
|
||||
]
|
||||
for test in test_data:
|
||||
log.debug('limit_offset_combo: %s', ', '.join([str(e) for e in test]))
|
||||
log.debug('limit_offset_combo: %s', ', '.join(str(e) for e in test))
|
||||
limit_offset_combo(*test)
|
||||
|
||||
def test_limit_with_offset_and_filter(self):
|
||||
@@ -283,7 +283,7 @@ class Test_LimitedOffsetDataProvider(Test_FilteredDataProvider):
|
||||
(1, 2, result_data[2:3], 0, 0, 0),
|
||||
]
|
||||
for test in test_data:
|
||||
log.debug('limit_offset_combo: %s', ', '.join([str(e) for e in test]))
|
||||
log.debug('limit_offset_combo: %s', ', '.join(str(e) for e in test))
|
||||
limit_offset_combo(*test)
|
||||
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ class Test_FilteredLineDataProvider(test_base_dataproviders.Test_FilteredDataPro
|
||||
(3, 2, result_data[2:3], 1, 1, 1),
|
||||
]
|
||||
for test in test_data:
|
||||
log.debug('limit_offset_combo: %s', ', '.join([str(e) for e in test]))
|
||||
log.debug('limit_offset_combo: %s', ', '.join(str(e) for e in test))
|
||||
limit_offset_combo(*test)
|
||||
|
||||
def test_provide_blank(self):
|
||||
|
||||
@@ -84,11 +84,11 @@ class BaseJobConfXmlParserTestCase(unittest.TestCase):
|
||||
template = {
|
||||
'assign_with': ' assign_with="%s"' % assign_with if assign_with is not None else '',
|
||||
'default': ' default="%s"' % default if default is not None else '',
|
||||
'handlers': '\n'.join([
|
||||
'handlers': '\n'.join(
|
||||
'<handler id="{id}"{tags}/>'.format(
|
||||
id=x['id'],
|
||||
tags=' tags="%s"' % x['tags'] if 'tags' in x else ''
|
||||
) for x in handlers]),
|
||||
) for x in handlers),
|
||||
}
|
||||
self._job_configuration_base_pools = base_pools
|
||||
self._write_config_from(HANDLER_TEMPLATE_JOB_CONF, template=template)
|
||||
|
||||
@@ -638,7 +638,7 @@ class HDAFilterParserTestCase(HDATestCase):
|
||||
self.log('the following filters should be parsable')
|
||||
# base
|
||||
self.assertORMFilter(self.filter_parser.parse_filter('id', 'in', [1, 2]))
|
||||
encoded_id_string = ','.join([self.app.security.encode_id(id_) for id_ in [1, 2]])
|
||||
encoded_id_string = ','.join(self.app.security.encode_id(id_) for id_ in [1, 2])
|
||||
self.assertORMFilter(self.filter_parser.parse_filter('encoded_id', 'in', encoded_id_string))
|
||||
self.assertORMFilter(self.filter_parser.parse_filter('create_time', 'le', '2015-03-15'))
|
||||
self.assertORMFilter(self.filter_parser.parse_filter('create_time', 'ge', '2015-03-15'))
|
||||
|
||||
@@ -329,7 +329,7 @@ class MappingTests(unittest.TestCase):
|
||||
task.add_metric("gx", "galaxy_slots", 5)
|
||||
task.add_metric("system", "system_name", "localhost")
|
||||
|
||||
big_value = ":".join(["%d" % i for i in range(2000)])
|
||||
big_value = ":".join("%d" % i for i in range(2000))
|
||||
task.add_metric("env", "BIG_PATH", big_value)
|
||||
self.persist(task)
|
||||
# Ensure big values truncated
|
||||
|
||||
@@ -13,8 +13,8 @@ FILLED_SIMPLE_TEMPLATE = """ echo 1
|
||||
echo 2
|
||||
"""
|
||||
LIST_COMPREHENSION_TEMPLATE = """#for $i in [1]:
|
||||
#set $v = "".join([str(_) for _ in [1] if _ == $i])
|
||||
echo $v
|
||||
#set $v = [str(_) for _ in [1] if _ == $i]
|
||||
echo $v[0]
|
||||
#end for
|
||||
"""
|
||||
DICT_COMPREHENSION_TEMPLATE = """#for $i in [1]:
|
||||
@@ -28,7 +28,7 @@ echo $v.pop()
|
||||
#end for
|
||||
"""
|
||||
GEN_EXPR_TEMPLATE = """#for $i in [1]:
|
||||
#set $v = list((_ for _ in [1] if _ == $i))
|
||||
#set $v = list(_ for _ in [1] if _ == $i)
|
||||
echo $v[0]
|
||||
#end for
|
||||
"""
|
||||
|
||||
@@ -15,7 +15,7 @@ def clean_multiline_string(multiline_string, sep='\n'):
|
||||
if not string_list[-1]:
|
||||
string_list = string_list[:-1]
|
||||
# return '\n'.join( docstrings )
|
||||
return ''.join([(s + '\n') for s in string_list])
|
||||
return ''.join((s + '\n') for s in string_list)
|
||||
|
||||
|
||||
__all__ = (
|
||||
|
||||
@@ -52,7 +52,7 @@ class VisualizationsRegistry_TestCase(unittest.TestCase):
|
||||
scatterplot = plugin_mgr.plugins['scatterplot']
|
||||
self.assertEqual(scatterplot.name, 'scatterplot')
|
||||
self.assertEqual(scatterplot.path, os.path.join(expected_plugins_path, 'scatterplot'))
|
||||
self.assertEqual(scatterplot.base_url, '/'.join([plugin_mgr.base_url, scatterplot.name]))
|
||||
self.assertEqual(scatterplot.base_url, '/'.join((plugin_mgr.base_url, scatterplot.name)))
|
||||
self.assertTrue(scatterplot.serves_templates)
|
||||
self.assertEqual(scatterplot.template_path, os.path.join(scatterplot.path, 'templates'))
|
||||
self.assertEqual(scatterplot.template_lookup.__class__.__name__, 'TemplateLookup')
|
||||
@@ -60,7 +60,7 @@ class VisualizationsRegistry_TestCase(unittest.TestCase):
|
||||
trackster = plugin_mgr.plugins['trackster']
|
||||
self.assertEqual(trackster.name, 'trackster')
|
||||
self.assertEqual(trackster.path, os.path.join(expected_plugins_path, 'trackster'))
|
||||
self.assertEqual(trackster.base_url, '/'.join([plugin_mgr.base_url, trackster.name]))
|
||||
self.assertEqual(trackster.base_url, '/'.join((plugin_mgr.base_url, trackster.name)))
|
||||
self.assertFalse(trackster.serves_templates)
|
||||
|
||||
def test_plugin_load(self):
|
||||
@@ -115,7 +115,7 @@ class VisualizationsRegistry_TestCase(unittest.TestCase):
|
||||
vis1 = plugin_mgr.plugins['vis1']
|
||||
self.assertEqual(vis1.name, 'vis1')
|
||||
self.assertEqual(vis1.path, os.path.join(expected_plugins_path, 'vis1'))
|
||||
self.assertEqual(vis1.base_url, '/'.join([plugin_mgr.base_url, vis1.name]))
|
||||
self.assertEqual(vis1.base_url, '/'.join((plugin_mgr.base_url, vis1.name)))
|
||||
self.assertTrue(vis1.serves_templates)
|
||||
self.assertEqual(vis1.template_path, os.path.join(vis1.path, 'templates'))
|
||||
self.assertEqual(vis1.template_lookup.__class__.__name__, 'TemplateLookup')
|
||||
@@ -123,7 +123,7 @@ class VisualizationsRegistry_TestCase(unittest.TestCase):
|
||||
vis2 = plugin_mgr.plugins['vis2']
|
||||
self.assertEqual(vis2.name, 'vis2')
|
||||
self.assertEqual(vis2.path, os.path.join(expected_plugins_path, 'vis2'))
|
||||
self.assertEqual(vis2.base_url, '/'.join([plugin_mgr.base_url, vis2.name]))
|
||||
self.assertEqual(vis2.base_url, '/'.join((plugin_mgr.base_url, vis2.name)))
|
||||
self.assertFalse(vis2.serves_templates)
|
||||
|
||||
mock_app_dir.remove()
|
||||
|
||||
Reference in New Issue
Block a user