You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bloodhound.apache.org by rj...@apache.org on 2013/06/12 03:36:28 UTC
svn commit: r1492033 - in /bloodhound/trunk/bloodhound_multiproduct:
multiproduct/env.py tests/env.py
Author: rjollos
Date: Wed Jun 12 01:36:27 2013
New Revision: 1492033
URL: http://svn.apache.org/r1492033
Log:
Whitespace cleanup.
Modified:
bloodhound/trunk/bloodhound_multiproduct/multiproduct/env.py
bloodhound/trunk/bloodhound_multiproduct/tests/env.py
Modified: bloodhound/trunk/bloodhound_multiproduct/multiproduct/env.py
URL: http://svn.apache.org/viewvc/bloodhound/trunk/bloodhound_multiproduct/multiproduct/env.py?rev=1492033&r1=1492032&r2=1492033&view=diff
==============================================================================
--- bloodhound/trunk/bloodhound_multiproduct/multiproduct/env.py (original)
+++ bloodhound/trunk/bloodhound_multiproduct/multiproduct/env.py Wed Jun 12 01:36:27 2013
@@ -864,9 +864,9 @@ class ProductEnvironment(Component, Comp
prefix = unicode_quote(self.product.prefix, safe="")
name = unicode_quote(self.product.name, safe="")
url = urlpattern.replace('$(', '%(') \
- .replace('%(envname)s', envname) \
- .replace('%(prefix)s', prefix) \
- .replace('%(name)s', name)
+ .replace('%(envname)s', envname) \
+ .replace('%(prefix)s', prefix) \
+ .replace('%(name)s', name)
if urlsplit(url).netloc:
# Absolute URLs
self._abs_href = Href(url)
@@ -939,4 +939,3 @@ resolve_product_href = ProductEnvironmen
# Override product-specific options
from multiproduct.config import ProductPermissionPolicyOption
PermissionSystem.policies.__class__ = ProductPermissionPolicyOption
-
Modified: bloodhound/trunk/bloodhound_multiproduct/tests/env.py
URL: http://svn.apache.org/viewvc/bloodhound/trunk/bloodhound_multiproduct/tests/env.py?rev=1492033&r1=1492032&r2=1492033&view=diff
==============================================================================
--- bloodhound/trunk/bloodhound_multiproduct/tests/env.py (original)
+++ bloodhound/trunk/bloodhound_multiproduct/tests/env.py Wed Jun 12 01:36:27 2013
@@ -72,8 +72,8 @@ class MultiproductTestCase(unittest.Test
"""Add logging capabilities to assertRaises
"""
def __init__(self, expected, test_case, expected_regexp=None):
- _AssertRaisesContext.__init__(
- self, expected, test_case, expected_regexp)
+ _AssertRaisesContext.__init__(self, expected, test_case,
+ expected_regexp)
self.test_case = test_case
@staticmethod
@@ -89,8 +89,8 @@ class MultiproductTestCase(unittest.Test
def __exit__(self, exc_type, exc_value, tb):
try:
- return _AssertRaisesContext.__exit__(self,
- exc_type, exc_value, tb)
+ return _AssertRaisesContext.__exit__(self, exc_type,
+ exc_value, tb)
except self.failureException, exc:
msg = self.test_case.exceptFailureMessage
if msg is not None:
@@ -110,8 +110,8 @@ class MultiproductTestCase(unittest.Test
if callableObj is None:
return self._AssertRaisesLoggingContext(excClass, self)
else:
- return unittest.TestCase.assertRaises(
- self, excClass, callableObj, *args, **kwargs)
+ return unittest.TestCase.assertRaises(self, excClass, callableObj,
+ *args, **kwargs)
# Product data
@@ -119,42 +119,42 @@ class MultiproductTestCase(unittest.Test
MAX_TEST_PRODUCT = 3
PRODUCT_DATA = {
- 'tp1' : {
- 'prefix':'tp1',
- 'name' : 'test product 1',
- 'description' : 'desc for tp1',
- },
- 'tp2' : {
- 'prefix':'tp2',
- 'name' : 'test product 2',
- 'description' : 'desc for tp2',
- },
- u'xü' : {
- 'prefix':u'xü',
- 'name' : 'Non-ASCII chars',
- 'description' : 'Unicode chars in name',
- },
- u'Ãberflüssigkeit' : {
- 'prefix':u'Ãberflüssigkeit',
- 'name' : 'Non-ASCII chars (long)',
- 'description' : 'Long name with unicode chars',
- },
- 'Foo Bar' : {
- 'prefix':'Foo Bar',
- 'name' : 'Whitespaces',
- 'description' : 'Whitespace chars in name',
- },
- 'Foo Bar#baz' : {
- 'prefix':'Foo Bar#baz',
- 'name' : 'Non-alphanumeric',
- 'description' : 'Special chars in name',
- },
- 'pl/de' : {
- 'prefix':'pl/de',
- 'name' : 'Path separator',
- 'description' : 'URL path separator in name',
- },
- }
+ 'tp1': {
+ 'prefix': 'tp1',
+ 'name': 'test product 1',
+ 'description': 'desc for tp1',
+ },
+ 'tp2': {
+ 'prefix': 'tp2',
+ 'name': 'test product 2',
+ 'description': 'desc for tp2',
+ },
+ u'xü': {
+ 'prefix': u'xü',
+ 'name': 'Non-ASCII chars',
+ 'description': 'Unicode chars in name',
+ },
+ u'Ãberflüssigkeit': {
+ 'prefix': u'Ãberflüssigkeit',
+ 'name': 'Non-ASCII chars (long)',
+ 'description': 'Long name with unicode chars',
+ },
+ 'Foo Bar': {
+ 'prefix': 'Foo Bar',
+ 'name': 'Whitespaces',
+ 'description': 'Whitespace chars in name',
+ },
+ 'Foo Bar#baz': {
+ 'prefix': 'Foo Bar#baz',
+ 'name': 'Non-alphanumeric',
+ 'description': 'Special chars in name',
+ },
+ 'pl/de': {
+ 'prefix': 'pl/de',
+ 'name': 'Path separator',
+ 'description': 'URL path separator in name',
+ },
+ }
# Test setup
@@ -191,8 +191,7 @@ class MultiproductTestCase(unittest.Test
config.save()
env.setup_log()
- env.log.info('%s test case: %s %s',
- '-' * 10, self.id(), '-' * 10)
+ env.log.info('%s test case: %s %s', '-' * 10, self.id(), '-' * 10)
# Clean-up logger instance and associated handler
# Otherwise large test suites will only result in ERROR eventually
@@ -247,10 +246,9 @@ class MultiproductTestCase(unittest.Test
with env.db_transaction as db:
for table, cols, vals in db_default.get_data(db):
if table != 'system':
- db.executemany('INSERT INTO %s (%s) VALUES (%s)' %
- (table, ','.join(cols),
- ','.join(['%s' for c in cols])),
- vals)
+ db.executemany('INSERT INTO %s (%s) VALUES (%s)'
+ % (table, ','.join(cols),
+ ','.join(['%s' for c in cols])), vals)
env.log.debug('Loaded default data')
def _mp_setup(self, **kwargs):
@@ -261,6 +259,7 @@ class MultiproductTestCase(unittest.Test
self._setup_test_log(self.env)
self._load_product_from_data(self.env, self.default_product)
+
class ProductEnvTestCase(EnvironmentTestCase, MultiproductTestCase):
r"""Test cases for Trac environments rewritten for product environments
"""
@@ -277,10 +276,12 @@ class ProductEnvTestCase(EnvironmentTest
self._upgrade_mp(self.global_env)
self._load_product_from_data(self.global_env, self.default_product)
try:
- self.env = ProductEnvironment(self.global_env, self.default_product)
- except :
+ self.env = ProductEnvironment(self.global_env,
+ self.default_product)
+ except:
# All tests should fail if anything goes wrong
- self.global_env.log.exception('Error creating product environment')
+ self.global_env.log.exception(
+ 'Error creating product environment')
self.env = None
except:
shutil.rmtree(self.env.path)
@@ -292,6 +293,7 @@ class ProductEnvTestCase(EnvironmentTest
EnvironmentTestCase.tearDown(self)
+
class ProductEnvApiTestCase(MultiproductTestCase):
"""Assertions for Apache(TM) Bloodhound product-specific extensions in
[https://issues.apache.org/bloodhound/wiki/Proposals/BEP-0003 BEP 3]
@@ -328,7 +330,7 @@ class ProductEnvApiTestCase(Multiproduct
def property_mock(attrnm, expected_self):
def assertAttrFwd(instance):
self.assertIs(instance, expected_self,
- "Mismatch in property '%s'" % (attrnm,))
+ "Mismatch in property '%s'" % (attrnm,))
raise AttrSuccess
return property(assertAttrFwd)
@@ -342,21 +344,22 @@ class ProductEnvApiTestCase(Multiproduct
if isinstance(original, MethodType):
translation = getattr(self.product_env, attrnm)
self.assertIs(translation.im_self, self.env,
- "'%s' not bound to global env in product env" %
- (attrnm,))
+ "'%s' not bound to global env in product env"
+ % (attrnm,))
self.assertIs(translation.im_func, original.im_func,
- "'%s' function differs in product env" % (attrnm,))
+ "'%s' function differs in product env"
+ % (attrnm,))
elif isinstance(original, (property, Option)):
# Intercept property access e.g. properties, Option, ...
- setattr(self.env.__class__, attrnm,
- property_mock(attrnm, self.env))
+ setattr(self.env.__class__, attrnm,
+ property_mock(attrnm, self.env))
self.exceptFailureMessage = 'Property %(attrnm)s'
with self.assertRaises(AttrSuccess) as cm_test_attr:
getattr(self.product_env, attrnm)
else:
- self.fail("Environment member %s has unexpected type" %
- (repr(original),))
+ self.fail("Environment member %s has unexpected type"
+ % (repr(original),))
finally:
self.env.__class__ = EnvironmentStub
@@ -368,13 +371,15 @@ class ProductEnvApiTestCase(Multiproduct
if isinstance(original, MethodType):
translation = getattr(self.product_env, attrnm)
self.assertIs(translation.im_self, self.product_env,
- "'%s' not bound to product env" % (attrnm,))
+ "'%s' not bound to product env" % (attrnm,))
self.assertIs(translation.im_func, original.im_func,
- "'%s' function differs in product env" % (attrnm,))
+ "'%s' function differs in product env"
+ % (attrnm,))
elif isinstance(original, property):
translation = getattr(ProductEnvironment, attrnm)
self.assertIs(original, translation,
- "'%s' property differs in product env" % (attrnm,))
+ "'%s' property differs in product env"
+ % (attrnm,))
def test_typecheck(self):
"""Testing env.__init__"""
@@ -384,8 +389,9 @@ class ProductEnvApiTestCase(Multiproduct
msg = str(cm_test.exception)
expected_msg = "Initializer must be called with " \
- "trac.env.Environment instance as first argument " \
- "(got multiproduct.env.ProductEnvironment instance instead)"
+ "trac.env.Environment instance as first argument " \
+ "(got multiproduct.env.ProductEnvironment instance " \
+ "instead)"
self.assertEqual(msg, expected_msg)
def test_component_enable(self):
@@ -408,11 +414,11 @@ class ProductEnvApiTestCase(Multiproduct
disable_component_in_config(product_env, cls)
expected_rules = {
- 'multiproduct' : True,
- 'trac' : True,
- 'trac.db' : True,
- cname : False,
- }
+ 'multiproduct': True,
+ 'trac': True,
+ 'trac.db': True,
+ cname: False,
+ }
self.assertEquals(expected_rules, global_env._component_rules)
self.assertEquals(expected_rules, product_env._component_rules)
@@ -478,8 +484,9 @@ class ProductEnvApiTestCase(Multiproduct
def test_path(self):
"""Testing env.path"""
- self.assertEqual(self.product_env.path,
- os.path.join(self.env.path, 'products', self.default_product))
+ self.assertEqual(self.product_env.path,
+ os.path.join(self.env.path, 'products',
+ self.default_product))
def test_env_config_inheritance(self):
"""Testing env.config"""
@@ -505,9 +512,9 @@ class ProductEnvApiTestCase(Multiproduct
self._load_product_from_data(self.env, prefix)
envgen1 = dict([prefix, ProductEnvironment(self.env, prefix)]
- for prefix in self.PRODUCT_DATA)
+ for prefix in self.PRODUCT_DATA)
envgen2 = dict([prefix, ProductEnvironment(self.env, prefix)]
- for prefix in self.PRODUCT_DATA)
+ for prefix in self.PRODUCT_DATA)
for prefix, env1 in envgen1.iteritems():
self.assertIs(env1, envgen2[prefix],
@@ -524,14 +531,15 @@ class ProductEnvApiTestCase(Multiproduct
else:
return products[0]
- envgen3 = dict([prefix, ProductEnvironment(self.env,
- load_product(prefix))]
- for prefix in self.PRODUCT_DATA)
+ envgen3 = dict([prefix, ProductEnvironment(self.env,
+ load_product(prefix))]
+ for prefix in self.PRODUCT_DATA)
for prefix, env1 in envgen1.iteritems():
self.assertIs(env1, envgen3[prefix],
"Identity check (by product model) '%s'" % (prefix,))
+
class ProductEnvHrefTestCase(MultiproductTestCase):
"""Assertions for resolution of product environment's base URL
[https://issues.apache.org/bloodhound/wiki/Proposals/BEP-0003 BEP 3]
@@ -602,11 +610,10 @@ class ProductEnvHrefTestCase(Multiproduc
def test_suite():
return unittest.TestSuite([
- unittest.makeSuite(ProductEnvTestCase,'test'),
- unittest.makeSuite(ProductEnvApiTestCase, 'test'),
- unittest.makeSuite(ProductEnvHrefTestCase, 'test'),
- ])
+ unittest.makeSuite(ProductEnvTestCase, 'test'),
+ unittest.makeSuite(ProductEnvApiTestCase, 'test'),
+ unittest.makeSuite(ProductEnvHrefTestCase, 'test'),
+ ])
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
-