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 2014/02/13 06:08:08 UTC

svn commit: r1567849 [7/17] - in /bloodhound/vendor/trac: 1.0-stable/ current/ current/contrib/ current/contrib/cgi-bin/ current/contrib/workflow/ current/doc/ current/doc/utils/ current/sample-plugins/ current/sample-plugins/permissions/ current/sampl...

Modified: bloodhound/vendor/trac/current/trac/tests/allwiki.py
URL: http://svn.apache.org/viewvc/bloodhound/vendor/trac/current/trac/tests/allwiki.py?rev=1567849&r1=1567848&r2=1567849&view=diff
==============================================================================
--- bloodhound/vendor/trac/current/trac/tests/allwiki.py (original)
+++ bloodhound/vendor/trac/current/trac/tests/allwiki.py Thu Feb 13 05:08:02 2014
@@ -1,3 +1,16 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2006-2013 Edgewall Software
+# All rights reserved.
+#
+# This software is licensed as described in the file COPYING, which
+# you should have received as part of this distribution. The terms
+# are also available at http://trac.edgewall.org/wiki/TracLicense.
+#
+# This software consists of voluntary contributions made by many
+# individuals. For the exact contribution history, see the revision
+# history and logs, available at http://trac.edgewall.org/log/.
+
 import unittest
 
 import trac.tests.wikisyntax

Modified: bloodhound/vendor/trac/current/trac/tests/attachment.py
URL: http://svn.apache.org/viewvc/bloodhound/vendor/trac/current/trac/tests/attachment.py?rev=1567849&r1=1567848&r2=1567849&view=diff
==============================================================================
--- bloodhound/vendor/trac/current/trac/tests/attachment.py (original)
+++ bloodhound/vendor/trac/current/trac/tests/attachment.py Thu Feb 13 05:08:02 2014
@@ -1,6 +1,19 @@
 # -*- coding: utf-8 -*-
+#
+# Copyright (C) 2005-2013 Edgewall Software
+# All rights reserved.
+#
+# This software is licensed as described in the file COPYING, which
+# you should have received as part of this distribution. The terms
+# are also available at http://trac.edgewall.org/wiki/TracLicense.
+#
+# This software consists of voluntary contributions made by many
+# individuals. For the exact contribution history, see the revision
+# history and logs, available at http://trac.edgewall.org/log/.
 
-import os.path
+from __future__ import with_statement
+
+import os
 import shutil
 from StringIO import StringIO
 import tempfile
@@ -43,8 +56,7 @@ class AttachmentTestCase(unittest.TestCa
 
     def setUp(self):
         self.env = EnvironmentStub()
-        self.env.path = os.path.join(tempfile.gettempdir(), 'trac-tempenv')
-        os.mkdir(self.env.path)
+        self.env.path = tempfile.mkdtemp(prefix='trac-tempenv-')
         self.attachments_dir = os.path.join(self.env.path, 'files',
                                             'attachments')
         self.env.config.set('trac', 'permission_policies',
@@ -52,6 +64,10 @@ class AttachmentTestCase(unittest.TestCa
         self.env.config.set('attachment', 'max_size', 512)
 
         self.perm = PermissionCache(self.env)
+        with self.env.db_transaction as db:
+            db("INSERT INTO wiki (name,version) VALUES ('WikiStart',1)")
+            db("INSERT INTO wiki (name,version) VALUES ('SomePage',1)")
+            db("INSERT INTO ticket (id) VALUES (42)")
 
     def tearDown(self):
         shutil.rmtree(self.env.path)
@@ -143,7 +159,7 @@ class AttachmentTestCase(unittest.TestCa
                                       hashes['42'][0:3], hashes['42'],
                                       hashes['foo.2.txt'] + '.txt'),
                          attachment.path)
-        self.assert_(os.path.exists(attachment.path))
+        self.assertTrue(os.path.exists(attachment.path))
 
     def test_insert_outside_attachments_dir(self):
         attachment = Attachment(self.env, '../../../../../sth/private', 42)
@@ -162,8 +178,8 @@ class AttachmentTestCase(unittest.TestCa
         attachment1.delete()
         attachment2.delete()
 
-        assert not os.path.exists(attachment1.path)
-        assert not os.path.exists(attachment2.path)
+        self.assertFalse(os.path.exists(attachment1.path))
+        self.assertFalse(os.path.exists(attachment2.path))
 
         attachments = Attachment.select(self.env, 'wiki', 'SomePage')
         self.assertEqual(0, len(list(attachments)))
@@ -190,7 +206,7 @@ class AttachmentTestCase(unittest.TestCa
         self.assertEqual(2, len(list(attachments)))
         attachments = Attachment.select(self.env, 'ticket', 123)
         self.assertEqual(0, len(list(attachments)))
-        assert os.path.exists(path1) and os.path.exists(attachment2.path)
+        self.assertTrue(os.path.exists(path1) and os.path.exists(attachment2.path))
 
         attachment1.reparent('ticket', 123)
         self.assertEqual('ticket', attachment1.parent_realm)
@@ -202,19 +218,19 @@ class AttachmentTestCase(unittest.TestCa
         self.assertEqual(1, len(list(attachments)))
         attachments = Attachment.select(self.env, 'ticket', 123)
         self.assertEqual(1, len(list(attachments)))
-        assert not os.path.exists(path1) and os.path.exists(attachment1.path)
-        assert os.path.exists(attachment2.path)
+        self.assertFalse(os.path.exists(path1) and os.path.exists(attachment1.path))
+        self.assertTrue(os.path.exists(attachment2.path))
 
     def test_legacy_permission_on_parent(self):
         """Ensure that legacy action tests are done on parent.  As
         `ATTACHMENT_VIEW` maps to `TICKET_VIEW`, the `TICKET_VIEW` is tested
         against the ticket's resource."""
         attachment = Attachment(self.env, 'ticket', 42)
-        self.assert_('ATTACHMENT_VIEW' in self.perm(attachment.resource))
+        self.assertTrue('ATTACHMENT_VIEW' in self.perm(attachment.resource))
 
     def test_resource_doesnt_exist(self):
         r = Resource('wiki', 'WikiStart').child('attachment', 'file.txt')
-        self.assertEqual(False, AttachmentModule(self.env).resource_exists(r))
+        self.assertFalse(AttachmentModule(self.env).resource_exists(r))
 
     def test_resource_exists(self):
         att = Attachment(self.env, 'wiki', 'WikiStart')
@@ -224,7 +240,7 @@ class AttachmentTestCase(unittest.TestCa
 
 def suite():
     suite = unittest.TestSuite()
-    suite.addTest(unittest.makeSuite(AttachmentTestCase, 'test'))
+    suite.addTest(unittest.makeSuite(AttachmentTestCase))
     return suite
 
 if __name__ == '__main__':

Added: bloodhound/vendor/trac/current/trac/tests/compat.py
URL: http://svn.apache.org/viewvc/bloodhound/vendor/trac/current/trac/tests/compat.py?rev=1567849&view=auto
==============================================================================
--- bloodhound/vendor/trac/current/trac/tests/compat.py (added)
+++ bloodhound/vendor/trac/current/trac/tests/compat.py Thu Feb 13 05:08:02 2014
@@ -0,0 +1,101 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2013 Edgewall Software
+# All rights reserved.
+#
+# This software is licensed as described in the file COPYING, which
+# you should have received as part of this distribution. The terms
+# are also available at http://trac.edgewall.org/wiki/TracLicense.
+#
+# This software consists of voluntary contributions made by many
+# individuals. For the exact contribution history, see the revision
+# history and logs, available at http://trac.edgewall.org/log/.
+
+"""Some test functions since Python 2.7 to provide backwards-compatibility
+with previous versions of Python from 2.5 onward.
+"""
+
+import os
+import shutil
+import sys
+import unittest
+
+
+if not hasattr(unittest.TestCase, 'assertIs'):
+    def assertIs(self, expr1, expr2, msg=None):
+        if expr1 is not expr2:
+            raise self.failureException(msg or '%r is not %r'
+                                               % (expr1, expr2))
+    unittest.TestCase.assertIs = assertIs
+
+
+if not hasattr(unittest.TestCase, 'assertIsNot'):
+    def assertIsNot(self, expr1, expr2, msg=None):
+        if expr1 is expr2:
+            raise self.failureException(msg or '%r is %r' % (expr1, expr2))
+    unittest.TestCase.assertIsNot = assertIsNot
+
+
+if not hasattr(unittest.TestCase, 'assertIsNone'):
+    def assertIsNone(self, obj, msg=None):
+        self.assertIs(obj, None, msg)
+    unittest.TestCase.assertIsNone = assertIsNone
+
+
+if not hasattr(unittest.TestCase, 'assertIsNotNone'):
+    def assertIsNotNone(self, obj, msg=None):
+        self.assertIsNot(obj, None, msg)
+    unittest.TestCase.assertIsNotNone = assertIsNotNone
+
+
+if not hasattr(unittest.TestCase, 'assertIn'):
+    def assertIn(self, member, container, msg=None):
+        if member not in container:
+            raise self.failureException(msg or '%r not in %r' %
+                                               (member, container))
+    unittest.TestCase.assertIn = assertIn
+
+
+if not hasattr(unittest.TestCase, 'assertNotIn'):
+    def assertNotIn(self, member, container, msg=None):
+        if member in container:
+            raise self.failureException(msg or '%r in %r' %
+                                               (member, container))
+    unittest.TestCase.assertNotIn = assertNotIn
+
+
+if not hasattr(unittest.TestCase, 'assertIsInstance'):
+    def assertIsInstance(self, obj, cls, msg=None):
+        if not isinstance(obj, cls):
+            raise self.failureException(msg or '%r is not an instance of %r' %
+                                               (obj, cls))
+    unittest.TestCase.assertIsInstance = assertIsInstance
+
+
+if not hasattr(unittest.TestCase, 'assertNotIsInstance'):
+    def assertNotIsInstance(self, obj, cls, msg=None):
+        if isinstance(obj, cls):
+            raise self.failureException(msg or '%r is an instance of %r' %
+                                               (obj, cls))
+    unittest.TestCase.assertNotIsInstance = assertNotIsInstance
+
+
+def rmtree(path):
+    import errno
+    def onerror(function, path, excinfo):
+        # `os.remove` fails for a readonly file on Windows.
+        # Then, it attempts to be writable and remove.
+        if function != os.remove:
+            raise
+        e = excinfo[1]
+        if isinstance(e, OSError) and e.errno == errno.EACCES:
+            mode = os.stat(path).st_mode
+            os.chmod(path, mode | 0666)
+            function(path)
+        else:
+            raise
+    if os.name == 'nt' and isinstance(path, str):
+        # Use unicode characters in order to allow non-ansi characters
+        # on Windows.
+        path = unicode(path, sys.getfilesystemencoding())
+    shutil.rmtree(path, onerror=onerror)

Modified: bloodhound/vendor/trac/current/trac/tests/config.py
URL: http://svn.apache.org/viewvc/bloodhound/vendor/trac/current/trac/tests/config.py?rev=1567849&r1=1567848&r2=1567849&view=diff
==============================================================================
--- bloodhound/vendor/trac/current/trac/tests/config.py (original)
+++ bloodhound/vendor/trac/current/trac/tests/config.py Thu Feb 13 05:08:02 2014
@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
 #
-# Copyright (C) 2005-2009 Edgewall Software
+# Copyright (C) 2005-2013 Edgewall Software
 # Copyright (C) 2005-2007 Christopher Lenz <cm...@gmx.de>
 # All rights reserved.
 #
@@ -20,7 +20,9 @@ import time
 import unittest
 
 from trac.config import *
-from trac.test import Configuration
+from trac.core import Component, Interface, implements
+from trac.test import Configuration, EnvironmentStub
+from trac.tests import compat
 from trac.util import create_file
 
 
@@ -29,6 +31,7 @@ class ConfigurationTestCase(unittest.Tes
     def setUp(self):
         tmpdir = os.path.realpath(tempfile.gettempdir())
         self.filename = os.path.join(tmpdir, 'trac-test.ini')
+        self.env = EnvironmentStub()
         self._write([])
         self._orig_registry = Option.registry
         Option.registry = {}
@@ -46,79 +49,80 @@ class ConfigurationTestCase(unittest.Tes
 
     def test_default(self):
         config = self._read()
-        self.assertEquals('', config.get('a', 'option'))
-        self.assertEquals('value', config.get('a', 'option', 'value'))
+        self.assertEqual('', config.get('a', 'option'))
+        self.assertEqual('value', config.get('a', 'option', 'value'))
 
         class Foo(object):
             option_a = Option('a', 'option', 'value')
 
-        self.assertEquals('value', config.get('a', 'option'))
+        self.assertEqual('value', config.get('a', 'option'))
 
     def test_default_bool(self):
         config = self._read()
-        self.assertEquals(False, config.getbool('a', 'option'))
-        self.assertEquals(True, config.getbool('a', 'option', 'yes'))
-        self.assertEquals(True, config.getbool('a', 'option', 1))
+        self.assertFalse(config.getbool('a', 'option'))
+        self.assertTrue(config.getbool('a', 'option', 'yes'))
+        self.assertTrue(config.getbool('a', 'option', 1))
 
         class Foo(object):
             option_a = Option('a', 'option', 'true')
 
-        self.assertEquals(True, config.getbool('a', 'option'))
+        self.assertTrue(config.getbool('a', 'option'))
 
     def test_default_int(self):
         config = self._read()
         self.assertRaises(ConfigurationError,
                           config.getint, 'a', 'option', 'b')
-        self.assertEquals(0, config.getint('a', 'option'))
-        self.assertEquals(1, config.getint('a', 'option', '1'))
-        self.assertEquals(1, config.getint('a', 'option', 1))
+        self.assertEqual(0, config.getint('a', 'option'))
+        self.assertEqual(1, config.getint('a', 'option', '1'))
+        self.assertEqual(1, config.getint('a', 'option', 1))
 
         class Foo(object):
             option_a = Option('a', 'option', '2')
 
-        self.assertEquals(2, config.getint('a', 'option'))
+        self.assertEqual(2, config.getint('a', 'option'))
 
     def test_default_float(self):
         config = self._read()
         self.assertRaises(ConfigurationError,
                           config.getfloat, 'a', 'option', 'b')
-        self.assertEquals(0.0, config.getfloat('a', 'option'))
-        self.assertEquals(1.2, config.getfloat('a', 'option', '1.2'))
-        self.assertEquals(1.2, config.getfloat('a', 'option', 1.2))
-        self.assertEquals(1.0, config.getfloat('a', 'option', 1))
+        self.assertEqual(0.0, config.getfloat('a', 'option'))
+        self.assertEqual(1.2, config.getfloat('a', 'option', '1.2'))
+        self.assertEqual(1.2, config.getfloat('a', 'option', 1.2))
+        self.assertEqual(1.0, config.getfloat('a', 'option', 1))
 
         class Foo(object):
             option_a = Option('a', 'option', '2.5')
 
-        self.assertEquals(2.5, config.getfloat('a', 'option'))
+        self.assertEqual(2.5, config.getfloat('a', 'option'))
 
     def test_default_path(self):
         config = self._read()
         class Foo(object):
             option_a = PathOption('a', 'opt1', 'file.ini')
             option_b = PathOption('a', 'opt2', '/somewhere/file.ini')
-        self.assertEquals('file.ini', config.get('a', 'opt1'))
+        self.assertEqual('file.ini', config.get('a', 'opt1'))
         self.assertNotEquals('file.ini', config.getpath('a', 'opt1'))
         self.assertTrue(os.path.isabs(config.getpath('a', 'opt1')))
-        self.assertEquals('/somewhere/file.ini', os.path.splitdrive(
-                config.getpath('a', 'opt2'))[1].replace('\\', '/'))
-        self.assertEquals('/none.ini', os.path.splitdrive(
-                config.getpath('a', 'opt3', '/none.ini'))[1].replace('\\', '/'))
+        self.assertEqual('/somewhere/file.ini', os.path.splitdrive(
+                         config.getpath('a', 'opt2'))[1].replace('\\', '/'))
+        self.assertEqual('/none.ini', os.path.splitdrive(
+                         config.getpath('a', 'opt3',
+                                        '/none.ini'))[1].replace('\\', '/'))
         self.assertNotEquals('none.ini', config.getpath('a', 'opt3', 'none.ini'))
 
     def test_read_and_get(self):
         self._write(['[a]', 'option = x'])
         config = self._read()
-        self.assertEquals('x', config.get('a', 'option'))
-        self.assertEquals('x', config.get('a', 'option', 'y'))
-        self.assertEquals('y', config.get('b', 'option2', 'y'))
+        self.assertEqual('x', config.get('a', 'option'))
+        self.assertEqual('x', config.get('a', 'option', 'y'))
+        self.assertEqual('y', config.get('b', 'option2', 'y'))
 
     def test_read_and_get_unicode(self):
         self._write([u'[ä]', u'öption = x'])
         config = self._read()
-        self.assertEquals('x', config.get(u'ä', u'öption'))
-        self.assertEquals('x', config.get(u'ä', u'öption', 'y'))
-        self.assertEquals('y', config.get('b', u'öption2', 'y'))
+        self.assertEqual('x', config.get(u'ä', u'öption'))
+        self.assertEqual('x', config.get(u'ä', u'öption', 'y'))
+        self.assertEqual('y', config.get('b', u'öption2', 'y'))
 
     def test_read_and_getbool(self):
         self._write(['[a]', 'option = yes', 'option2 = true',
@@ -126,73 +130,74 @@ class ConfigurationTestCase(unittest.Tes
                      'option5 = 1', 'option6 = 123', 'option7 = 123.456',
                      'option8 = disabled', 'option9 = 0', 'option10 = 0.0'])
         config = self._read()
-        self.assertEquals(True, config.getbool('a', 'option'))
-        self.assertEquals(True, config.getbool('a', 'option', False))
-        self.assertEquals(True, config.getbool('a', 'option2'))
-        self.assertEquals(True, config.getbool('a', 'option3'))
-        self.assertEquals(True, config.getbool('a', 'option4'))
-        self.assertEquals(True, config.getbool('a', 'option5'))
-        self.assertEquals(True, config.getbool('a', 'option6'))
-        self.assertEquals(True, config.getbool('a', 'option7'))
-        self.assertEquals(False, config.getbool('a', 'option8'))
-        self.assertEquals(False, config.getbool('a', 'option9'))
-        self.assertEquals(False, config.getbool('a', 'option10'))
-        self.assertEquals(False, config.getbool('b', 'option_b'))
-        self.assertEquals(False, config.getbool('b', 'option_b', False))
-        self.assertEquals(False, config.getbool('b', 'option_b', 'disabled'))
+        self.assertTrue(config.getbool('a', 'option'))
+        self.assertTrue(config.getbool('a', 'option', False))
+        self.assertTrue(config.getbool('a', 'option2'))
+        self.assertTrue(config.getbool('a', 'option3'))
+        self.assertTrue(config.getbool('a', 'option4'))
+        self.assertTrue(config.getbool('a', 'option5'))
+        self.assertTrue(config.getbool('a', 'option6'))
+        self.assertTrue(config.getbool('a', 'option7'))
+        self.assertFalse(config.getbool('a', 'option8'))
+        self.assertFalse(config.getbool('a', 'option9'))
+        self.assertFalse(config.getbool('a', 'option10'))
+        self.assertFalse(config.getbool('b', 'option_b'))
+        self.assertFalse(config.getbool('b', 'option_b', False))
+        self.assertFalse(config.getbool('b', 'option_b', 'disabled'))
 
     def test_read_and_getint(self):
         self._write(['[a]', 'option = 42'])
         config = self._read()
-        self.assertEquals(42, config.getint('a', 'option'))
-        self.assertEquals(42, config.getint('a', 'option', 25))
-        self.assertEquals(0, config.getint('b', 'option2'))
-        self.assertEquals(25, config.getint('b', 'option2', 25))
-        self.assertEquals(25, config.getint('b', 'option2', '25'))
+        self.assertEqual(42, config.getint('a', 'option'))
+        self.assertEqual(42, config.getint('a', 'option', 25))
+        self.assertEqual(0, config.getint('b', 'option2'))
+        self.assertEqual(25, config.getint('b', 'option2', 25))
+        self.assertEqual(25, config.getint('b', 'option2', '25'))
 
     def test_read_and_getfloat(self):
         self._write(['[a]', 'option = 42.5'])
         config = self._read()
-        self.assertEquals(42.5, config.getfloat('a', 'option'))
-        self.assertEquals(42.5, config.getfloat('a', 'option', 25.3))
-        self.assertEquals(0, config.getfloat('b', 'option2'))
-        self.assertEquals(25.3, config.getfloat('b', 'option2', 25.3))
-        self.assertEquals(25.0, config.getfloat('b', 'option2', 25))
-        self.assertEquals(25.3, config.getfloat('b', 'option2', '25.3'))
+        self.assertEqual(42.5, config.getfloat('a', 'option'))
+        self.assertEqual(42.5, config.getfloat('a', 'option', 25.3))
+        self.assertEqual(0, config.getfloat('b', 'option2'))
+        self.assertEqual(25.3, config.getfloat('b', 'option2', 25.3))
+        self.assertEqual(25.0, config.getfloat('b', 'option2', 25))
+        self.assertEqual(25.3, config.getfloat('b', 'option2', '25.3'))
 
     def test_read_and_getlist(self):
         self._write(['[a]', 'option = foo, bar, baz'])
         config = self._read()
-        self.assertEquals(['foo', 'bar', 'baz'],
-                          config.getlist('a', 'option'))
-        self.assertEquals([],
-                          config.getlist('b', 'option2'))
-        self.assertEquals(['foo', 'bar', 'baz'],
-                    config.getlist('b', 'option2', ['foo', 'bar', 'baz']))
-        self.assertEquals(['foo', 'bar', 'baz'],
-                    config.getlist('b', 'option2', 'foo, bar, baz'))
+        self.assertEqual(['foo', 'bar', 'baz'],
+                         config.getlist('a', 'option'))
+        self.assertEqual([],
+                         config.getlist('b', 'option2'))
+        self.assertEqual(['foo', 'bar', 'baz'],
+                         config.getlist('b', 'option2',
+                                        ['foo', 'bar', 'baz']))
+        self.assertEqual(['foo', 'bar', 'baz'],
+                         config.getlist('b', 'option2', 'foo, bar, baz'))
 
     def test_read_and_getlist_sep(self):
         self._write(['[a]', 'option = foo | bar | baz'])
         config = self._read()
-        self.assertEquals(['foo', 'bar', 'baz'],
-                          config.getlist('a', 'option', sep='|'))
+        self.assertEqual(['foo', 'bar', 'baz'],
+                         config.getlist('a', 'option', sep='|'))
 
     def test_read_and_getlist_keep_empty(self):
         self._write(['[a]', 'option = ,bar,baz'])
         config = self._read()
-        self.assertEquals(['bar', 'baz'], config.getlist('a', 'option'))
-        self.assertEquals(['', 'bar', 'baz'],
-                          config.getlist('a', 'option', keep_empty=True))
+        self.assertEqual(['bar', 'baz'], config.getlist('a', 'option'))
+        self.assertEqual(['', 'bar', 'baz'],
+                         config.getlist('a', 'option', keep_empty=True))
 
     def test_read_and_getlist_false_values(self):
         config = self._read()
         values = [None, False, '', 'foo', u'', u'bar',
                   0, 0L, 0.0, 0j, 42, 43.0]
-        self.assertEquals([False, 'foo', u'bar', 0, 0L, 0.0, 0j, 42, 43.0],
-                          config.getlist('a', 'false', values))
-        self.assertEquals(values, config.getlist('a', 'false', values,
-                                                 keep_empty=True))
+        self.assertEqual([False, 'foo', u'bar', 0, 0L, 0.0, 0j, 42, 43.0],
+                         config.getlist('a', 'false', values))
+        self.assertEqual(values, config.getlist('a', 'false', values,
+                                                keep_empty=True))
 
     def test_read_and_choice(self):
         self._write(['[a]', 'option = 2', 'invalid = d'])
@@ -208,8 +213,83 @@ class ConfigurationTestCase(unittest.Tes
                 self.config = config
 
         foo = Foo()
-        self.assertEquals('2', foo.option)
-        self.assertEquals('1', foo.other)
+        self.assertEqual('2', foo.option)
+        self.assertEqual('1', foo.other)
+        self.assertRaises(ConfigurationError, getattr, foo, 'invalid')
+
+    def test_read_and_getextensionoption(self):
+        self._write(['[a]', 'option = ImplA', 'invalid = ImplB'])
+        config = self._read()
+
+        class IDummy(Interface):
+            pass
+
+        class ImplA(Component):
+            implements(IDummy)
+
+        class Foo(Component):
+            default1 = (ExtensionOption)('a', 'default1', IDummy)
+            default2 = (ExtensionOption)('a', 'default2', IDummy, 'ImplA')
+            default3 = (ExtensionOption)('a', 'default3', IDummy, 'ImplB')
+            option = (ExtensionOption)('a', 'option', IDummy)
+            option2 = (ExtensionOption)('a', 'option', IDummy, 'ImplB')
+            invalid = (ExtensionOption)('a', 'invalid', IDummy)
+
+            def __init__(self):
+                self.config = config
+
+        foo = Foo(self.env)
+        self.assertRaises(ConfigurationError, getattr, foo, 'default1')
+        self.assertIsInstance(foo.default2, ImplA)
+        self.assertRaises(ConfigurationError, getattr, foo, 'default3')
+        self.assertIsInstance(foo.option, ImplA)
+        self.assertIsInstance(foo.option2, ImplA)
+        self.assertRaises(ConfigurationError, getattr, foo, 'invalid')
+
+    def test_read_and_getorderedextensionsoption(self):
+        self._write(['[a]', 'option = ImplA, ImplB',
+                     'invalid = ImplB, ImplD'])
+        config = self._read()
+
+        class IDummy(Interface):
+            pass
+
+        class ImplA(Component):
+            implements(IDummy)
+
+        class ImplB(Component):
+            implements(IDummy)
+
+        class ImplC(Component):
+            implements(IDummy)
+
+        class Foo(Component):
+            # enclose in parentheses to avoid messages extraction
+            default1 = (OrderedExtensionsOption)('a', 'default1', IDummy,
+                                                 include_missing=False)
+            default2 = (OrderedExtensionsOption)('a', 'default2', IDummy)
+            default3 = (OrderedExtensionsOption)('a', 'default3', IDummy,
+                                                 'ImplB, ImplC',
+                                                 include_missing=False)
+            option = (OrderedExtensionsOption)('a', 'option', IDummy,
+                                               include_missing=False)
+            invalid = (OrderedExtensionsOption)('a', 'invalid', IDummy)
+
+            def __init__(self):
+                self.config = config
+
+        foo = Foo(self.env)
+        self.assertEqual([], foo.default1)
+        self.assertEqual(3, len(foo.default2))
+        self.assertIsInstance(foo.default2[0], ImplA)
+        self.assertIsInstance(foo.default2[1], ImplB)
+        self.assertIsInstance(foo.default2[2], ImplC)
+        self.assertEqual(2, len(foo.default3))
+        self.assertIsInstance(foo.default3[0], ImplB)
+        self.assertIsInstance(foo.default3[1], ImplC)
+        self.assertEqual(2, len(foo.option))
+        self.assertIsInstance(foo.option[0], ImplA)
+        self.assertIsInstance(foo.option[1], ImplB)
         self.assertRaises(ConfigurationError, getattr, foo, 'invalid')
 
     def test_getpath(self):
@@ -218,12 +298,20 @@ class ConfigurationTestCase(unittest.Tes
         config.set('a', 'path_a', os.path.join(base, 'here', 'absolute.txt'))
         config.set('a', 'path_b', 'thisdir.txt')
         config.set('a', 'path_c', os.path.join(os.pardir, 'parentdir.txt'))
-        self.assertEquals(os.path.join(base, 'here', 'absolute.txt'),
-                          config.getpath('a', 'path_a'))
-        self.assertEquals(os.path.join(base, 'thisdir.txt'),
-                          config.getpath('a', 'path_b'))
-        self.assertEquals(os.path.join(os.path.dirname(base), 'parentdir.txt'),
-                          config.getpath('a', 'path_c'))
+        self.assertEqual(os.path.join(base, 'here', 'absolute.txt'),
+                         config.getpath('a', 'path_a'))
+        self.assertEqual(os.path.join(base, 'thisdir.txt'),
+                         config.getpath('a', 'path_b'))
+        self.assertEqual(os.path.join(os.path.dirname(base), 'parentdir.txt'),
+                         config.getpath('a', 'path_c'))
+
+    def test_set_raises(self):
+        class Foo(object):
+            option = Option('a', 'option', 'value')
+
+        f = Foo()
+        self.assertRaises(AttributeError, setattr, f, 'option',
+                          Option('a', 'option2', 'value2'))
 
     def test_set_and_save(self):
         config = self._read()
@@ -233,57 +321,57 @@ class ConfigurationTestCase(unittest.Tes
         config.set(u'aä', 'option1', u"Voilà l'été") # unicode
         # Note: the following would depend on the locale.getpreferredencoding()
         # config.set('a', 'option3', "Voil\xe0 l'\xe9t\xe9") # latin-1
-        self.assertEquals('x', config.get(u'aä', u'öption0'))
-        self.assertEquals(u"Voilà l'été", config.get(u'aä', 'option1'))
-        self.assertEquals(u"Voilà l'été", config.get(u'aä', 'option2'))
+        self.assertEqual('x', config.get(u'aä', u'öption0'))
+        self.assertEqual(u"Voilà l'été", config.get(u'aä', 'option1'))
+        self.assertEqual(u"Voilà l'été", config.get(u'aä', 'option2'))
         config.save()
 
         configfile = open(self.filename, 'r')
-        self.assertEquals(['# -*- coding: utf-8 -*-\n',
-                           '\n',
-                           '[aä]\n',
-                           "option1 = Voilà l'été\n",
-                           "option2 = Voilà l'été\n",
-                           'öption0 = x\n',
-                           # "option3 = Voilà l'été\n",
-                           '\n',
-                           '[b]\n',
-                           'öption0 = y\n',
-                           '\n'],
-                          configfile.readlines())
+        self.assertEqual(['# -*- coding: utf-8 -*-\n',
+                          '\n',
+                          '[aä]\n',
+                          "option1 = Voilà l'été\n",
+                          "option2 = Voilà l'été\n",
+                          'öption0 = x\n',
+                          # "option3 = Voilà l'été\n",
+                          '\n',
+                          '[b]\n',
+                          'öption0 = y\n',
+                          '\n'],
+                         configfile.readlines())
         configfile.close()
         config2 = Configuration(self.filename)
-        self.assertEquals('x', config2.get(u'aä', u'öption0'))
-        self.assertEquals(u"Voilà l'été", config2.get(u'aä', 'option1'))
-        self.assertEquals(u"Voilà l'été", config2.get(u'aä', 'option2'))
-        # self.assertEquals(u"Voilà l'été", config2.get('a', 'option3'))
+        self.assertEqual('x', config2.get(u'aä', u'öption0'))
+        self.assertEqual(u"Voilà l'été", config2.get(u'aä', 'option1'))
+        self.assertEqual(u"Voilà l'été", config2.get(u'aä', 'option2'))
+        # self.assertEqual(u"Voilà l'été", config2.get('a', 'option3'))
 
     def test_set_and_save_inherit(self):
         def testcb():
             config = self._read()
             config.set('a', 'option2', "Voilà l'été")  # UTF-8
             config.set('a', 'option1', u"Voilà l'été") # unicode
-            self.assertEquals('x', config.get('a', 'option'))
-            self.assertEquals(u"Voilà l'été", config.get('a', 'option1'))
-            self.assertEquals(u"Voilà l'été", config.get('a', 'option2'))
+            self.assertEqual('x', config.get('a', 'option'))
+            self.assertEqual(u"Voilà l'été", config.get('a', 'option1'))
+            self.assertEqual(u"Voilà l'été", config.get('a', 'option2'))
             config.save()
 
             configfile = open(self.filename, 'r')
-            self.assertEquals(['# -*- coding: utf-8 -*-\n',
-                               '\n',
-                               '[a]\n',
-                               "option1 = Voilà l'été\n",
-                               "option2 = Voilà l'été\n",
-                               '\n',
-                               '[inherit]\n',
-                               "file = trac-site.ini\n",
-                               '\n'],
-                              configfile.readlines())
+            self.assertEqual(['# -*- coding: utf-8 -*-\n',
+                              '\n',
+                              '[a]\n',
+                              "option1 = Voilà l'été\n",
+                              "option2 = Voilà l'été\n",
+                              '\n',
+                              '[inherit]\n',
+                              "file = trac-site.ini\n",
+                              '\n'],
+                             configfile.readlines())
             configfile.close()
             config2 = Configuration(self.filename)
-            self.assertEquals('x', config2.get('a', 'option'))
-            self.assertEquals(u"Voilà l'été", config2.get('a', 'option1'))
-            self.assertEquals(u"Voilà l'été", config2.get('a', 'option2'))
+            self.assertEqual('x', config2.get('a', 'option'))
+            self.assertEqual(u"Voilà l'été", config2.get('a', 'option1'))
+            self.assertEqual(u"Voilà l'été", config2.get('a', 'option2'))
         self._test_with_inherit(testcb)
 
     def test_simple_remove(self):
@@ -292,106 +380,106 @@ class ConfigurationTestCase(unittest.Tes
         config.get('a', 'option') # populates the cache
         config.set(u'aä', u'öption', u'öne')
         config.remove('a', 'option')
-        self.assertEquals('', config.get('a', 'option'))
+        self.assertEqual('', config.get('a', 'option'))
         config.remove(u'aä', u'öption')
-        self.assertEquals('', config.get('aä', 'öption'))
+        self.assertEqual('', config.get('aä', 'öption'))
         config.remove('a', 'option2') # shouldn't fail
         config.remove('b', 'option2') # shouldn't fail
 
     def test_sections(self):
         self._write(['[a]', 'option = x', '[b]', 'option = y'])
         config = self._read()
-        self.assertEquals(['a', 'b'], config.sections())
+        self.assertEqual(['a', 'b'], config.sections())
 
         class Foo(object):
             # enclose in parentheses to avoid messages extraction
             section_c = (ConfigSection)('c', 'Doc for c')
             option_c = Option('c', 'option', 'value')
 
-        self.assertEquals(['a', 'b', 'c'], config.sections())
+        self.assertEqual(['a', 'b', 'c'], config.sections())
         foo = Foo()
         foo.config = config
-        self.assert_(foo.section_c is config['c'])
-        self.assertEquals('value', foo.section_c.get('option'))
+        self.assertTrue(foo.section_c is config['c'])
+        self.assertEqual('value', foo.section_c.get('option'))
 
     def test_sections_unicode(self):
         self._write([u'[aä]', u'öption = x', '[b]', 'option = y'])
         config = self._read()
-        self.assertEquals([u'aä', 'b'], config.sections())
+        self.assertEqual([u'aä', 'b'], config.sections())
 
         class Foo(object):
             option_c = Option(u'cä', 'option', 'value')
 
-        self.assertEquals([u'aä', 'b', u'cä'], config.sections())
+        self.assertEqual([u'aä', 'b', u'cä'], config.sections())
 
     def test_options(self):
         self._write(['[a]', 'option = x', '[b]', 'option = y'])
         config = self._read()
-        self.assertEquals(('option', 'x'), iter(config.options('a')).next())
-        self.assertEquals(('option', 'y'), iter(config.options('b')).next())
+        self.assertEqual(('option', 'x'), iter(config.options('a')).next())
+        self.assertEqual(('option', 'y'), iter(config.options('b')).next())
         self.assertRaises(StopIteration, iter(config.options('c')).next)
-        self.assertEquals('option', iter(config['a']).next())
-        self.assertEquals('option', iter(config['b']).next())
+        self.assertEqual('option', iter(config['a']).next())
+        self.assertEqual('option', iter(config['b']).next())
         self.assertRaises(StopIteration, iter(config['c']).next)
 
         class Foo(object):
             option_a = Option('a', 'b', 'c')
 
-        self.assertEquals([('option', 'x'), ('b', 'c')],
-                                list(config.options('a')))
+        self.assertEqual([('option', 'x'), ('b', 'c')],
+                         list(config.options('a')))
 
     def test_options_unicode(self):
         self._write([u'[ä]', u'öption = x', '[b]', 'option = y'])
         config = self._read()
-        self.assertEquals((u'öption', 'x'), iter(config.options(u'ä')).next())
-        self.assertEquals(('option', 'y'), iter(config.options('b')).next())
+        self.assertEqual((u'öption', 'x'), iter(config.options(u'ä')).next())
+        self.assertEqual(('option', 'y'), iter(config.options('b')).next())
         self.assertRaises(StopIteration, iter(config.options('c')).next)
-        self.assertEquals(u'öption', iter(config['ä']).next())
+        self.assertEqual(u'öption', iter(config['ä']).next())
 
         class Foo(object):
             option_a = Option(u'ä', u'öption2', 'c')
 
-        self.assertEquals([(u'öption', 'x'), (u'öption2', 'c')],
-                                list(config.options(u'ä')))
+        self.assertEqual([(u'öption', 'x'), (u'öption2', 'c')],
+                         list(config.options(u'ä')))
 
     def test_has_option(self):
         config = self._read()
-        self.assertEquals(False, config.has_option('a', 'option'))
-        self.assertEquals(False, 'option' in config['a'])
+        self.assertFalse(config.has_option('a', 'option'))
+        self.assertFalse('option' in config['a'])
         self._write(['[a]', 'option = x'])
         config = self._read()
-        self.assertEquals(True, config.has_option('a', 'option'))
-        self.assertEquals(True, 'option' in config['a'])
+        self.assertTrue(config.has_option('a', 'option'))
+        self.assertTrue('option' in config['a'])
 
         class Foo(object):
             option_a = Option('a', 'option2', 'x2')
 
-        self.assertEquals(True, config.has_option('a', 'option2'))
+        self.assertTrue(config.has_option('a', 'option2'))
 
     def test_has_option_unicode(self):
         config = self._read()
-        self.assertEquals(False, config.has_option(u'ä', u'öption'))
-        self.assertEquals(False, u'öption' in config[u'ä'])
+        self.assertFalse(config.has_option(u'ä', u'öption'))
+        self.assertFalse(u'öption' in config[u'ä'])
         self._write([u'[ä]', u'öption = x'])
         config = self._read()
-        self.assertEquals(True, config.has_option(u'ä', u'öption'))
-        self.assertEquals(True, u'öption' in config[u'ä'])
+        self.assertTrue(config.has_option(u'ä', u'öption'))
+        self.assertTrue(u'öption' in config[u'ä'])
 
         class Foo(object):
             option_a = Option(u'ä', u'öption2', 'x2')
 
-        self.assertEquals(True, config.has_option(u'ä', u'öption2'))
+        self.assertTrue(config.has_option(u'ä', u'öption2'))
 
     def test_reparse(self):
         self._write(['[a]', 'option = x'])
         config = self._read()
-        self.assertEquals('x', config.get('a', 'option'))
+        self.assertEqual('x', config.get('a', 'option'))
         time.sleep(2) # needed because of low mtime granularity,
                       # especially on fat filesystems
 
         self._write(['[a]', 'option = y'])
         config.parse_if_needed()
-        self.assertEquals('y', config.get('a', 'option'))
+        self.assertEqual('y', config.get('a', 'option'))
 
     def test_inherit_one_level(self):
         def testcb():
@@ -401,7 +489,7 @@ class ConfigurationTestCase(unittest.Tes
             config.remove('a', 'option') # Should *not* remove option in parent
             self.assertEqual('x', config.get('a', 'option'))
             self.assertEqual([('option', 'x')], list(config.options('a')))
-            self.assertEqual(True, 'a' in config)
+            self.assertTrue('a' in config)
         self._test_with_inherit(testcb)
 
     def test_inherit_multiple(self):
@@ -441,6 +529,89 @@ class ConfigurationTestCase(unittest.Tes
             os.remove(site1)
             os.rmdir(os.path.dirname(site1))
 
+    def test_option_with_raw_default(self):
+        class Foo(object):
+            # enclose in parentheses to avoid messages extraction
+            option_none = (Option)('a', 'none', None)
+            option_blah = (Option)('a', 'blah', u'Blàh!')
+            option_true = (BoolOption)('a', 'true', True)
+            option_false = (BoolOption)('a', 'false', False)
+            option_list = (ListOption)('a', 'list', ['#cc0', 4.2, 42L, 0, None,
+                                                     True, False, None],
+                                       sep='|')
+            option_choice = (ChoiceOption)('a', 'choice', [-42, 42])
+
+        config = self._read()
+        config.set_defaults()
+        config.save()
+        with open(self.filename, 'r') as f:
+            self.assertEqual('# -*- coding: utf-8 -*-\n',            f.next())
+            self.assertEqual('\n',                                   f.next())
+            self.assertEqual('[a]\n',                                f.next())
+            self.assertEqual('blah = Blàh!\n',                       f.next())
+            self.assertEqual('choice = -42\n',                       f.next())
+            self.assertEqual('false = disabled\n',                   f.next())
+            self.assertEqual('list = #cc0|4.2|42|0||enabled|disabled|\n',
+                             f.next())
+            self.assertEqual('# none = <inherited>\n',               f.next())
+            self.assertEqual('true = enabled\n',                     f.next())
+            self.assertEqual('\n',                                   f.next())
+            self.assertRaises(StopIteration, f.next)
+
+    def test_unicode_option_with_raw_default(self):
+        class Foo(object):
+            # enclose in parentheses to avoid messages extraction
+            option_none = (Option)(u'résumé', u'nöné', None)
+            option_blah = (Option)(u'résumé', u'bláh', u'Blàh!')
+            option_true = (BoolOption)(u'résumé', u'trüé', True)
+            option_false = (BoolOption)(u'résumé', u'fálsé', False)
+            option_list = (ListOption)(u'résumé', u'liśt',
+                                       [u'#ccö', 4.2, 42L, 0, None, True,
+                                        False, None],
+                                       sep='|')
+            option_choice = (ChoiceOption)(u'résumé', u'chöicé', [-42, 42])
+
+        config = self._read()
+        config.set_defaults()
+        config.save()
+        with open(self.filename, 'r') as f:
+            self.assertEqual('# -*- coding: utf-8 -*-\n',            f.next())
+            self.assertEqual('\n',                                   f.next())
+            self.assertEqual('[résumé]\n',                           f.next())
+            self.assertEqual('bláh = Blàh!\n',                       f.next())
+            self.assertEqual('chöicé = -42\n',                       f.next())
+            self.assertEqual('fálsé = disabled\n',                   f.next())
+            self.assertEqual('liśt = #ccö|4.2|42|0||enabled|disabled|\n',
+                             f.next())
+            self.assertEqual('# nöné = <inherited>\n',               f.next())
+            self.assertEqual('trüé = enabled\n',                     f.next())
+            self.assertEqual('\n',                                   f.next())
+            self.assertRaises(StopIteration, f.next)
+
+    def test_save_changes_mtime(self):
+        """Test that each save operation changes the file modification time."""
+        class Foo(object):
+            IntOption('section', 'option', 1)
+        sconfig = self._read()
+        sconfig.set_defaults()
+        sconfig.save()
+        rconfig = self._read()
+        self.assertEqual(1, rconfig.getint('section', 'option'))
+        sconfig.set('section', 'option', 2)
+        time.sleep(1.0 - time.time() % 1.0)
+        sconfig.save()
+        rconfig.parse_if_needed()
+        self.assertEqual(2, rconfig.getint('section', 'option'))
+
+    def test_touch_changes_mtime(self):
+        """Test that each touch command changes the file modification time."""
+        config = self._read()
+        time.sleep(1.0 - time.time() % 1.0)
+        config.touch()
+        mtime = os.stat(self.filename).st_mtime
+        config.touch()
+        self.assertNotEqual(mtime, os.stat(self.filename).st_mtime)
+
     def _test_with_inherit(self, testcb):
         sitename = os.path.join(tempfile.gettempdir(), 'trac-site.ini')
         try:
@@ -454,7 +625,7 @@ class ConfigurationTestCase(unittest.Tes
 
 
 def suite():
-    return unittest.makeSuite(ConfigurationTestCase, 'test')
+    return unittest.makeSuite(ConfigurationTestCase)
 
 if __name__ == '__main__':
     unittest.main(defaultTest='suite')

Modified: bloodhound/vendor/trac/current/trac/tests/contentgen.py
URL: http://svn.apache.org/viewvc/bloodhound/vendor/trac/current/trac/tests/contentgen.py?rev=1567849&r1=1567848&r2=1567849&view=diff
==============================================================================
--- bloodhound/vendor/trac/current/trac/tests/contentgen.py (original)
+++ bloodhound/vendor/trac/current/trac/tests/contentgen.py Thu Feb 13 05:08:02 2014
@@ -1,11 +1,23 @@
-#!/usr/bin/python
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2008-2013 Edgewall Software
+# All rights reserved.
+#
+# This software is licensed as described in the file COPYING, which
+# you should have received as part of this distribution. The terms
+# are also available at http://trac.edgewall.org/wiki/TracLicense.
+#
+# This software consists of voluntary contributions made by many
+# individuals. For the exact contribution history, see the revision
+# history and logs, available at http://trac.edgewall.org/log/.
 
 import random
-
+import uuid
 
 try:
-    all_words = [x.strip() for x in open('/usr/share/dict/words').readlines() if x.strip().isalpha()]
-except Exception:
+    all_words = [x.strip() for x in open('/usr/share/dict/words').readlines()
+                           if x.strip().isalpha()]
+except IOError:
     all_words = [
         'one',
         'two',
@@ -19,37 +31,50 @@ except Exception:
         'ten',
     ]
 
-def random_word():
+
+def random_word(min_length=1):
     word = random.choice(all_words)
+    while len(word) < min_length:
+        word = random.choice(all_words)
     # Do not return CamelCase words
     if word[0].isupper():
         word = word.lower().capitalize()
     return word
 
+
 _random_unique_camels = []
 def random_unique_camel():
     """Returns a unique camelcase word pair"""
     while True:
-        camel = random_word().title() + random_word().title()
+        camel = random_word(2).title() + random_word(2).title()
         if not camel in _random_unique_camels:
             break
     _random_unique_camels.append(camel)
     return camel
 
+
 def random_sentence(word_count=None):
-    if word_count == None:
+    """Generates a random sentence. The first word consists of the first 8
+    characters of a uuid to ensure uniqueness.
+
+    :param word_count: number of words in the sentence
+    """
+    if word_count is None:
         word_count = random.randint(1, 20)
-    words = [random_word() for x in range(word_count)]
+    words = [random_word() for x in range(word_count - 1)]
+    words.insert(0, str(uuid.uuid1()).split('-')[0])
     return '%s.' % ' '.join(words)
 
+
 def random_paragraph(sentence_count=None):
-    if sentence_count == None:
+    if sentence_count is None:
         sentence_count = random.randint(1, 10)
     sentences = [random_sentence(random.randint(2, 15)) for x in range(sentence_count)]
     return '  '.join(sentences)
 
+
 def random_page(paragraph_count=None):
-    if paragraph_count == None:
+    if paragraph_count is None:
         paragraph_count = random.randint(1, 10)
     paragraphs = [random_paragraph(random.randint(1, 5)) for x in range(paragraph_count)]
     return '\r\n\r\n'.join(paragraphs)

Modified: bloodhound/vendor/trac/current/trac/tests/core.py
URL: http://svn.apache.org/viewvc/bloodhound/vendor/trac/current/trac/tests/core.py?rev=1567849&r1=1567848&r2=1567849&view=diff
==============================================================================
--- bloodhound/vendor/trac/current/trac/tests/core.py (original)
+++ bloodhound/vendor/trac/current/trac/tests/core.py Thu Feb 13 05:08:02 2014
@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
 #
-# Copyright (C)2005-2009 Edgewall Software
+# Copyright (C) 2005-2009 Edgewall Software
 # Copyright (C) 2005 Christopher Lenz <cm...@gmx.de>
 # All rights reserved.
 #
@@ -15,6 +15,8 @@
 # Author: Christopher Lenz <cm...@gmx.de>
 
 from trac.core import *
+from trac.core import ComponentManager
+from trac.tests import compat
 
 import unittest
 
@@ -51,7 +53,7 @@ class ComponentTestCase(unittest.TestCas
         registry.
         """
         from trac.core import ComponentMeta
-        assert Component not in ComponentMeta._components
+        self.assertNotIn(Component, ComponentMeta._components)
         self.assertRaises(TracError, self.compmgr.__getitem__, Component)
 
     def test_abstract_component_not_registered(self):
@@ -62,7 +64,7 @@ class ComponentTestCase(unittest.TestCas
         from trac.core import ComponentMeta
         class AbstractComponent(Component):
             abstract = True
-        assert AbstractComponent not in ComponentMeta._components
+        self.assertNotIn(AbstractComponent, ComponentMeta._components)
         self.assertRaises(TracError, self.compmgr.__getitem__,
                           AbstractComponent)
 
@@ -82,8 +84,8 @@ class ComponentTestCase(unittest.TestCas
         """
         class ComponentA(Component):
             pass
-        assert self.compmgr[ComponentA]
-        assert ComponentA(self.compmgr)
+        self.assertTrue(self.compmgr[ComponentA])
+        self.assertTrue(ComponentA(self.compmgr))
 
     def test_component_identity(self):
         """
@@ -94,9 +96,9 @@ class ComponentTestCase(unittest.TestCas
             pass
         c1 = ComponentA(self.compmgr)
         c2 = ComponentA(self.compmgr)
-        assert c1 is c2, 'Expected same component instance'
+        self.assertIs(c1, c2, 'Expected same component instance')
         c2 = self.compmgr[ComponentA]
-        assert c1 is c2, 'Expected same component instance'
+        self.assertIs(c1, c2, 'Expected same component instance')
 
     def test_component_initializer(self):
         """
@@ -212,7 +214,7 @@ class ComponentTestCase(unittest.TestCas
             def test(self):
                 return 'x'
         tests = iter(ComponentA(self.compmgr).tests)
-        self.assertEquals('x', tests.next().test())
+        self.assertEqual('x', tests.next().test())
         self.assertRaises(StopIteration, tests.next)
 
     def test_extension_point_with_two_extensions(self):
@@ -231,7 +233,7 @@ class ComponentTestCase(unittest.TestCas
             def test(self):
                 return 'y'
         results = [test.test() for test in ComponentA(self.compmgr).tests]
-        self.assertEquals(['x', 'y'], sorted(results))
+        self.assertEqual(['x', 'y'], sorted(results))
 
     def test_inherited_extension_point(self):
         """
@@ -246,7 +248,7 @@ class ComponentTestCase(unittest.TestCas
             def test(self):
                 return 'x'
         tests = iter(ConcreteComponent(self.compmgr).tests)
-        self.assertEquals('x', tests.next().test())
+        self.assertEqual('x', tests.next().test())
         self.assertRaises(StopIteration, tests.next)
 
     def test_inherited_implements(self):
@@ -260,7 +262,7 @@ class ComponentTestCase(unittest.TestCas
         class ConcreteComponent(BaseComponent):
             pass
         from trac.core import ComponentMeta
-        assert ConcreteComponent in ComponentMeta._registry.get(ITest, [])
+        self.assertIn(ConcreteComponent, ComponentMeta._registry.get(ITest, []))
 
     def test_inherited_implements_multilevel(self):
         """
@@ -276,8 +278,8 @@ class ComponentTestCase(unittest.TestCas
         class ConcreteComponent(ChildComponent):
             pass
         from trac.core import ComponentMeta
-        assert ConcreteComponent in ComponentMeta._registry.get(ITest, [])
-        assert ConcreteComponent in ComponentMeta._registry.get(IOtherTest, [])
+        self.assertIn(ConcreteComponent, ComponentMeta._registry.get(ITest, []))
+        self.assertIn(ConcreteComponent, ComponentMeta._registry.get(IOtherTest, []))
 
     def test_component_manager_component(self):
         """
@@ -295,17 +297,41 @@ class ComponentTestCase(unittest.TestCas
             def test(self):
                 return 'x'
         mgr = ManagerComponent('Test', 42)
-        assert id(mgr) == id(mgr[ManagerComponent])
+        self.assertEqual(id(mgr), id(mgr[ManagerComponent]))
         tests = iter(mgr.tests)
-        self.assertEquals('x', tests.next().test())
+        self.assertEqual('x', tests.next().test())
         self.assertRaises(StopIteration, tests.next)
 
+    def test_component_manager_component_isolation(self):
+        """
+        Verify that a component manager that is also a component will only
+        be listed in extension points for components instantiated in
+        its scope.
+
+        See bh:comment:5:ticket:438 and #11121
+        """
+        class ManagerComponentA(ComponentManager, Component):
+            implements(ITest)
+            def test(self):
+                pass
+
+        class ManagerComponentB(ManagerComponentA):
+            pass
+
+        class Tester(Component):
+            tests = ExtensionPoint(ITest)
+
+        mgrA = ManagerComponentA()
+        mgrB = ManagerComponentB()
+
+        self.assertEqual([mgrA], Tester(mgrA).tests)
+        self.assertEqual([mgrB], Tester(mgrB).tests)
+
     def test_instantiation_doesnt_enable(self):
         """
         Make sure that a component disabled by the ComponentManager is not
         implicitly enabled by instantiating it directly.
         """
-        from trac.core import ComponentManager
         class DisablingComponentManager(ComponentManager):
             def is_component_enabled(self, cls):
                 return False
@@ -313,11 +339,21 @@ class ComponentTestCase(unittest.TestCas
             pass
         mgr = DisablingComponentManager()
         instance = ComponentA(mgr)
-        self.assertEqual(None, mgr[ComponentA])
+        self.assertIsNone(mgr[ComponentA])
+
+    def test_invalid_argument_raises(self):
+        """
+        AssertionError is raised when first argument to initializer is not a
+        ComponentManager instance.
+        """
+        class ComponentA(Component):
+            pass
+        self.assertRaises(AssertionError, Component)
 
 
 def suite():
-    return unittest.makeSuite(ComponentTestCase, 'test')
+    return unittest.makeSuite(ComponentTestCase)
+
 
 if __name__ == '__main__':
-    unittest.main()
+    unittest.main(defaultTest='suite')

Modified: bloodhound/vendor/trac/current/trac/tests/env.py
URL: http://svn.apache.org/viewvc/bloodhound/vendor/trac/current/trac/tests/env.py?rev=1567849&r1=1567848&r2=1567849&view=diff
==============================================================================
--- bloodhound/vendor/trac/current/trac/tests/env.py (original)
+++ bloodhound/vendor/trac/current/trac/tests/env.py Thu Feb 13 05:08:02 2014
@@ -1,53 +1,123 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2003-2013 Edgewall Software
+# All rights reserved.
+#
+# This software is licensed as described in the file COPYING, which
+# you should have received as part of this distribution. The terms
+# are also available at http://trac.edgewall.org/wiki/TracLicense.
+#
+# This software consists of voluntary contributions made by many
+# individuals. For the exact contribution history, see the revision
+# history and logs, available at http://trac.edgewall.org/log/.
+
 from __future__ import with_statement
 
+import shutil
+import tempfile
+import unittest
+
+from trac.tests import compat
 from trac import db_default
+from trac.core import ComponentManager
 from trac.env import Environment
+from trac.test import EnvironmentStub
+
+
+class EnvironmentCreatedWithoutData(Environment):
+    def __init__(self, path, create=False, options=[]):
+        ComponentManager.__init__(self)
+
+        self.path = path
+        self.systeminfo = []
+        self.href = self.abs_href = None
+
+        if create:
+            self.create(options)
+        else:
+            self.verify()
+            self.setup_config()
 
-import os.path
-import unittest
-import tempfile
-import shutil
+
+class EmptyEnvironmentTestCase(unittest.TestCase):
+
+    def setUp(self):
+        env_path = tempfile.mkdtemp(prefix='trac-tempenv-')
+        self.env = EnvironmentCreatedWithoutData(env_path, create=True)
+
+    def tearDown(self):
+        self.env.shutdown() # really closes the db connections
+        shutil.rmtree(self.env.path)
+
+    def test_get_version(self):
+        """Testing env.get_version"""
+        self.assertFalse(self.env.get_version())
 
 
 class EnvironmentTestCase(unittest.TestCase):
 
     def setUp(self):
-        env_path = os.path.join(tempfile.gettempdir(), 'trac-tempenv')
+        env_path = tempfile.mkdtemp(prefix='trac-tempenv-')
         self.env = Environment(env_path, create=True)
+        self.env.config.set('trac', 'base_url',
+                            'http://trac.edgewall.org/some/path')
+        self.env.config.save()
 
     def tearDown(self):
-        with self.env.db_query as db:
-            db.close()
         self.env.shutdown() # really closes the db connections
         shutil.rmtree(self.env.path)
 
+    def test_db_exc(self):
+        db_exc = self.env.db_exc
+        self.assertTrue(hasattr(db_exc, 'IntegrityError'))
+        self.assertIs(db_exc, self.env.db_exc)
+
+    def test_abs_href(self):
+        abs_href = self.env.abs_href
+        self.assertEqual('http://trac.edgewall.org/some/path', abs_href())
+        self.assertIs(abs_href, self.env.abs_href)
+
+    def test_href(self):
+        href = self.env.href
+        self.assertEqual('/some/path', href())
+        self.assertIs(href, self.env.href)
+
     def test_get_version(self):
         """Testing env.get_version"""
-        assert self.env.get_version() == db_default.db_version
+        self.assertEqual(db_default.db_version, self.env.get_version())
 
     def test_get_known_users(self):
         """Testing env.get_known_users"""
         with self.env.db_transaction as db:
             db.executemany("INSERT INTO session VALUES (%s,%s,0)",
-               [('123', 0),('tom', 1), ('joe', 1), ('jane', 1)])
+                [('123', 0), ('tom', 1), ('joe', 1), ('jane', 1)])
             db.executemany("INSERT INTO session_attribute VALUES (%s,%s,%s,%s)",
-               [('123', 0, 'email', 'a@example.com'),
-                ('tom', 1, 'name', 'Tom'),
-                ('tom', 1, 'email', 'tom@example.com'),
-                ('joe', 1, 'email', 'joe@example.com'),
-                ('jane', 1, 'name', 'Jane')])
+                [('123', 0, 'email', 'a@example.com'),
+                 ('tom', 1, 'name', 'Tom'),
+                 ('tom', 1, 'email', 'tom@example.com'),
+                 ('joe', 1, 'email', 'joe@example.com'),
+                 ('jane', 1, 'name', 'Jane')])
         users = {}
         for username, name, email in self.env.get_known_users():
             users[username] = (name, email)
 
-        assert not users.has_key('anonymous')
+        self.assertTrue('anonymous' not in users)
         self.assertEqual(('Tom', 'tom@example.com'), users['tom'])
         self.assertEqual((None, 'joe@example.com'), users['joe'])
         self.assertEqual(('Jane', None), users['jane'])
 
+    def test_is_component_enabled(self):
+        self.assertEqual(True, Environment.required)
+        self.assertEqual(True, self.env.is_component_enabled(Environment))
+        self.assertEqual(False, EnvironmentStub.required)
+        self.assertEqual(None, self.env.is_component_enabled(EnvironmentStub))
+
 
 def suite():
-    return unittest.makeSuite(EnvironmentTestCase,'test')
+    suite = unittest.TestSuite()
+    suite.addTest(unittest.makeSuite(EnvironmentTestCase))
+    suite.addTest(unittest.makeSuite(EmptyEnvironmentTestCase))
+    return suite
 
 if __name__ == '__main__':
     unittest.main(defaultTest='suite')

Modified: bloodhound/vendor/trac/current/trac/tests/functional/__init__.py
URL: http://svn.apache.org/viewvc/bloodhound/vendor/trac/current/trac/tests/functional/__init__.py?rev=1567849&r1=1567848&r2=1567849&view=diff
==============================================================================
--- bloodhound/vendor/trac/current/trac/tests/functional/__init__.py (original)
+++ bloodhound/vendor/trac/current/trac/tests/functional/__init__.py Thu Feb 13 05:08:02 2014
@@ -1,4 +1,17 @@
-#!/usr/bin/python
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2008-2013 Edgewall Software
+# All rights reserved.
+#
+# This software is licensed as described in the file COPYING, which
+# you should have received as part of this distribution. The terms
+# are also available at http://trac.edgewall.org/wiki/TracLicense.
+#
+# This software consists of voluntary contributions made by many
+# individuals. For the exact contribution history, see the revision
+# history and logs, available at http://trac.edgewall.org/log/.
+
 """functional_tests
 
 While unittests work well for testing facets of an implementation, they fail to
@@ -42,17 +55,19 @@ Requirements:
  - lxml for XHTML validation (optional)
 """
 
+import exceptions
 import os
+import shutil
 import signal
+import stat
 import sys
 import time
-import shutil
-import stat
 import unittest
-import exceptions
+from datetime import datetime, timedelta
 
 import trac
-from trac.tests.functional.compat import close_fds, rmtree
+from trac.tests.compat import rmtree
+from trac.util.compat import close_fds
 
 # Handle missing twill so we can print a useful 'SKIP'
 # message.  We import subprocess first to allow customizing it on Windows
@@ -60,7 +75,7 @@ from trac.tests.functional.compat import
 # is allowed to load first, its (unmodified) copy will always be loaded.
 import subprocess
 
-from better_twill import twill, b, tc, ConnectError
+from trac.tests.functional.better_twill import twill, b, tc, ConnectError
 
 try:
     # This is the first indicator of whether the subversion bindings are
@@ -70,11 +85,15 @@ try:
 except ImportError:
     has_svn = False
 
-from datetime import datetime, timedelta
+try:
+    from configobj import ConfigObj
+except ImportError:
+    ConfigObj = None
+    print "SKIP: fine-grained permission tests (ConfigObj not installed)"
 
+from trac.test import TestSetup, TestCaseSetup
 from trac.tests.contentgen import random_sentence, random_page, random_word, \
     random_unique_camel
-from trac.test import TestSetup, TestCaseSetup
 
 internal_error = 'Trac detected an internal error:'
 
@@ -135,10 +154,16 @@ if twill:
 
     class FunctionalTwillTestCaseSetup(FunctionalTestCaseSetup):
         failureException = twill.errors.TwillAssertionError
+
 else:
     # We're going to have to skip the functional tests
+    class FunctionalTestSuite(TestSetup):
+        def __init__(self):
+            raise ImportError("Twill not installed")
+
     class FunctionalTwillTestCaseSetup:
         pass
+
     class FunctionalTestCaseSetup:
         pass
 
@@ -149,15 +174,33 @@ def regex_owned_by(username):
     return '(Owned by:(<[^>]*>|\\n| )*%s)' % username
 
 
+def functionalSuite():
+    suite = FunctionalTestSuite()
+    return suite
+
+
 def suite():
-    if twill:
-        from trac.tests.functional.testcases import suite
-        suite = suite()
-    else:
-        diagnostic = "SKIP: functional tests"
-        if not twill:
-            diagnostic += " (no twill installed)"
-        print diagnostic
+    try:
+        suite = functionalSuite()
+        import trac.tests.functional.testcases
+        trac.tests.functional.testcases.functionalSuite(suite)
+        import trac.versioncontrol.tests
+        trac.versioncontrol.tests.functionalSuite(suite)
+        import trac.ticket.tests
+        trac.ticket.tests.functionalSuite(suite)
+        import trac.prefs.tests
+        trac.prefs.tests.functionalSuite(suite)
+        import trac.wiki.tests
+        trac.wiki.tests.functionalSuite(suite)
+        import trac.timeline.tests
+        trac.timeline.tests.functionalSuite(suite)
+        import trac.admin.tests
+        trac.admin.tests.functionalSuite(suite)
+        # The db tests should be last since the backup test occurs there.
+        import trac.db.tests
+        trac.db.tests.functionalSuite(suite)
+    except ImportError, e:
+        print("SKIP: functional tests (%s)" % e)
         # No tests to run, provide an empty suite.
         suite = unittest.TestSuite()
     return suite

Modified: bloodhound/vendor/trac/current/trac/tests/functional/better_twill.py
URL: http://svn.apache.org/viewvc/bloodhound/vendor/trac/current/trac/tests/functional/better_twill.py?rev=1567849&r1=1567848&r2=1567849&view=diff
==============================================================================
--- bloodhound/vendor/trac/current/trac/tests/functional/better_twill.py (original)
+++ bloodhound/vendor/trac/current/trac/tests/functional/better_twill.py Thu Feb 13 05:08:02 2014
@@ -1,4 +1,16 @@
-#!/usr/bin/python
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2008-2013 Edgewall Software
+# All rights reserved.
+#
+# This software is licensed as described in the file COPYING, which
+# you should have received as part of this distribution. The terms
+# are also available at http://trac.edgewall.org/wiki/TracLicense.
+#
+# This software consists of voluntary contributions made by many
+# individuals. For the exact contribution history, see the revision
+# history and logs, available at http://trac.edgewall.org/log/.
+
 """better_twill is a small wrapper around twill to set some sane defaults and
 monkey-patch some better versions of some of twill's methods.
 It also handles twill's absense.
@@ -36,9 +48,9 @@ except ImportError:
 
 if twill:
     # We want Trac to generate valid html, and therefore want to test against
-    # the html as generated by Trac.  "tidy" tries to clean up broken html, and
-    # is responsible for one difficult to track down testcase failure (for
-    # #5497).  Therefore we turn it off here.
+    # the html as generated by Trac.  "tidy" tries to clean up broken html,
+    # and is responsible for one difficult to track down testcase failure
+    # (for #5497).  Therefore we turn it off here.
     twill.commands.config('use_tidy', '0')
 
     # We use a transparent proxy to access the global browser object through
@@ -90,9 +102,9 @@ if twill:
                 context = data.splitlines()[max(0, entry.line - 5):
                                             entry.line + 6]
                 msg.append("\n# %s\n# URL: %s\n# Line %d, column %d\n\n%s\n"
-                    % (entry.message, entry.filename,
-                       entry.line, entry.column,
-                       "\n".join([each.decode('utf-8') for each in context])))
+                           % (entry.message, entry.filename, entry.line,
+                              entry.column, "\n".join([each.decode('utf-8')
+                                                       for each in context])))
             return "\n".join(msg).encode('ascii', 'xmlcharrefreplace')
 
         def _validate_xhtml(func_name, *args, **kwargs):
@@ -120,6 +132,8 @@ if twill:
         """Write the current html to a file.  Name the file based on the
         current testcase.
         """
+        import unittest
+
         frame = sys._getframe()
         while frame:
             if frame.f_code.co_name in ('runTest', 'setUp', 'tearDown'):
@@ -127,12 +141,19 @@ if twill:
                 testname = testcase.__class__.__name__
                 tracdir = testcase._testenv.tracdir
                 break
+            elif isinstance(frame.f_locals.get('self'), unittest.TestCase):
+                testcase = frame.f_locals['self']
+                testname = '%s.%s' % (testcase.__class__.__name__,
+                                      testcase._testMethodName)
+                tracdir = testcase._testenv.tracdir
+                break
             frame = frame.f_back
         else:
             # We didn't find a testcase in the stack, so we have no clue what's
             # going on.
             raise Exception("No testcase was found on the stack.  This was "
-                "really not expected, and I don't know how to handle it.")
+                            "really not expected, and I don't know how to "
+                            "handle it.")
 
         filename = os.path.join(tracdir, 'log', "%s.html" % testname)
         html_file = open(filename, 'w')
@@ -163,8 +184,8 @@ if twill:
         if formname is not None: # enhancement to directly specify the form
             browser._browser.form = browser.get_form(formname)
         old_submit(fieldname)
-
     b.submit = better_browser_submit
+
     def better_submit(fieldname=None, formname=None):
         b.submit(fieldname, formname)
     tc.submit = better_submit
@@ -186,15 +207,15 @@ if twill:
         control = b.get_form_field(form, fieldname)
 
         if not control.is_of_kind('file'):
-            raise twill.errors.TwillException('ERROR: field is not a file '
-                                              'upload field!')
+            raise twill.errors.TwillException("ERROR: field is not a file "
+                                              "upload field!")
 
         b.clicked(form, control)
         control.add_file(fp, content_type, filename)
     tc.formfile = better_formfile
 
-    # Twill's tc.find() does not provide any guidance on what we got instead of
-    # what was expected.
+    # Twill's tc.find() does not provide any guidance on what we got
+    # instead of what was expected.
     def better_find(what, flags='', tcfind=tc.find):
         try:
             tcfind(what, flags)
@@ -203,6 +224,7 @@ if twill:
             args = e.args + (filename,)
             raise twill.errors.TwillAssertionError(*args)
     tc.find = better_find
+
     def better_notfind(what, flags='', tcnotfind=tc.notfind):
         try:
             tcnotfind(what, flags)
@@ -211,6 +233,7 @@ if twill:
             args = e.args + (filename,)
             raise twill.errors.TwillAssertionError(*args)
     tc.notfind = better_notfind
+
     # Same for tc.url - no hint about what went wrong!
     def better_url(should_be, tcurl=tc.url):
         try:

Modified: bloodhound/vendor/trac/current/trac/tests/functional/compat.py
URL: http://svn.apache.org/viewvc/bloodhound/vendor/trac/current/trac/tests/functional/compat.py?rev=1567849&r1=1567848&r2=1567849&view=diff
==============================================================================
--- bloodhound/vendor/trac/current/trac/tests/functional/compat.py (original)
+++ bloodhound/vendor/trac/current/trac/tests/functional/compat.py Thu Feb 13 05:08:02 2014
@@ -1,18 +1,15 @@
-#!/usr/bin/python
-import os
-import shutil
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2008-2013 Edgewall Software
+# All rights reserved.
+#
+# This software is licensed as described in the file COPYING, which
+# you should have received as part of this distribution. The terms
+# are also available at http://trac.edgewall.org/wiki/TracLicense.
+#
+# This software consists of voluntary contributions made by many
+# individuals. For the exact contribution history, see the revision
+# history and logs, available at http://trac.edgewall.org/log/.
 
 from trac.util.compat import close_fds
-
-# On Windows, shutil.rmtree doesn't remove files with the read-only
-# attribute set, so this function explicitly removes it on every error
-# before retrying.  Even on Linux, shutil.rmtree chokes on read-only
-# directories, so we use this version in all cases.
-# Fix from http://bitten.edgewall.org/changeset/521
-def rmtree(root):
-    """Catch shutil.rmtree failures on Windows when files are read-only."""
-    def _handle_error(fn, path, excinfo):
-        os.chmod(path, 0666)
-        fn(path)
-    return shutil.rmtree(root, onerror=_handle_error)
-
+from trac.tests.compat import rmtree

Modified: bloodhound/vendor/trac/current/trac/tests/functional/svntestenv.py
URL: http://svn.apache.org/viewvc/bloodhound/vendor/trac/current/trac/tests/functional/svntestenv.py?rev=1567849&r1=1567848&r2=1567849&view=diff
==============================================================================
--- bloodhound/vendor/trac/current/trac/tests/functional/svntestenv.py (original)
+++ bloodhound/vendor/trac/current/trac/tests/functional/svntestenv.py Thu Feb 13 05:08:02 2014
@@ -1,10 +1,24 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2009-2014 Edgewall Software
+# All rights reserved.
+#
+# This software is licensed as described in the file COPYING, which
+# you should have received as part of this distribution. The terms
+# are also available at http://trac.edgewall.org/wiki/TracLicense.
+#
+# This software consists of voluntary contributions made by many
+# individuals. For the exact contribution history, see the revision
+# history and logs, available at http://trac.edgewall.org/log/.
+
 import os
 import re
 from subprocess import call
 
 from testenv import FunctionalTestEnvironment
-from trac.tests.functional.compat import close_fds
 from trac.tests.functional import logfile
+from trac.util.compat import close_fds
+
 
 class SvnFunctionalTestEnvironment(FunctionalTestEnvironment):
     def work_dir(self):
@@ -18,14 +32,15 @@ class SvnFunctionalTestEnvironment(Funct
         Initialize a repo of the type :attr:`self.repotype`.
         """
         if call(["svnadmin", "create", self.repo_path_for_initenv()],
-                 stdout=logfile, stderr=logfile, close_fds=close_fds):
+                stdout=logfile, stderr=logfile, close_fds=close_fds):
             raise Exception('unable to create subversion repository')
-        if call(['svn', 'co', self.repo_url(), self.work_dir()], stdout=logfile,
-                 stderr=logfile, close_fds=close_fds):
+        if call(['svn', 'co', self.repo_url(), self.work_dir()],
+                stdout=logfile, stderr=logfile, close_fds=close_fds):
             raise Exception('Checkout from %s failed.' % self.repo_url())
 
     def destroy_repo(self):
-        """The deletion of the testenvironment will remove the repo as well."""
+        """The deletion of the test environment will remove the
+        repo as well."""
         pass
 
     def repo_url(self):
@@ -48,11 +63,12 @@ class SvnFunctionalTestEnvironment(Funct
             self._testenv.svn_mkdir(["abc", "def"], "Add dirs")
 
         """
-        self.call_in_workdir(['svn', '--username=%s' % username, 'mkdir', '-m', msg]
-                + [self.repo_url() + '/' + d for d in paths])
+        self.call_in_workdir(['svn', '--username=%s' % username,
+                              'mkdir', '-m', msg]
+                             + [self.repo_url() + '/' + d for d in paths])
         self.call_in_workdir(['svn', 'update'])
 
-    def svn_add(self, filename, data):
+    def svn_add(self, filename, data, msg=None, username='admin'):
         """Subversion helper to add a file to the given path within the main
         repository.
 
@@ -67,8 +83,10 @@ class SvnFunctionalTestEnvironment(Funct
         self.call_in_workdir(['svn', 'add', filename])
         environ = os.environ.copy()
         environ['LC_ALL'] = 'C'     # Force English messages in svn
-        output = self.call_in_workdir(['svn', '--username=admin', 'commit', '-m',
-                        'Add %s' % filename, filename], environ=environ)
+        msg = 'Add %s' % filename if msg is None else msg
+        output = self.call_in_workdir(['svn', '--username=%s' % username,
+                                       'commit', '-m', msg, filename],
+                                      environ=environ)
         try:
             revision = re.search(r'Committed revision ([0-9]+)\.',
                                  output).group(1)
@@ -77,3 +95,5 @@ class SvnFunctionalTestEnvironment(Funct
             raise Exception(*args)
         return int(revision)
 
+    def call_in_workdir(self, args, environ=None):
+        return self.call_in_dir(self.work_dir(), args, environ)

Modified: bloodhound/vendor/trac/current/trac/tests/functional/testcases.py
URL: http://svn.apache.org/viewvc/bloodhound/vendor/trac/current/trac/tests/functional/testcases.py?rev=1567849&r1=1567848&r2=1567849&view=diff
==============================================================================
--- bloodhound/vendor/trac/current/trac/tests/functional/testcases.py (original)
+++ bloodhound/vendor/trac/current/trac/tests/functional/testcases.py Thu Feb 13 05:08:02 2014
@@ -1,17 +1,46 @@
-# -*- encoding: utf-8 -*-
-#!/usr/bin/python
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2008-2013 Edgewall Software
+# All rights reserved.
+#
+# This software is licensed as described in the file COPYING, which
+# you should have received as part of this distribution. The terms
+# are also available at http://trac.edgewall.org/wiki/TracLicense.
+#
+# This software consists of voluntary contributions made by many
+# individuals. For the exact contribution history, see the revision
+# history and logs, available at http://trac.edgewall.org/log/.
+
 import os
+
 from trac.tests.functional import *
+from trac.util import create_file
+
+
+class TestAttachmentNonexistentParent(FunctionalTwillTestCaseSetup):
+    def runTest(self):
+        """TracError should be raised when navigating to the attachment
+        page for a nonexistent resource."""
+        self._tester.go_to_wiki('NonexistentPage')
+        tc.find("The page NonexistentPage does not exist. "
+                "You can create it here.")
+        tc.find(r"\bCreate this page\b")
+
+        tc.go(self._tester.url + '/attachment/wiki/NonexistentPage')
+        tc.find('<h1>Trac Error</h1>\s+<p class="message">'
+                'Parent resource NonexistentPage doesn\'t exist</p>')
 
 
 class RegressionTestRev6017(FunctionalTwillTestCaseSetup):
     def runTest(self):
         """Test for regression of the plugin reload fix in r6017"""
         # Setup the DeleteTicket plugin
-        plugin = open(os.path.join(self._testenv.command_cwd, 'sample-plugins',
-            'workflow', 'DeleteTicket.py')).read()
-        open(os.path.join(self._testenv.tracdir, 'plugins', 'DeleteTicket.py'),
-             'w').write(plugin)
+        plugin = open(os.path.join(self._testenv.command_cwd,
+                                   'sample-plugins', 'workflow',
+                                   'DeleteTicket.py')).read()
+        open(os.path.join(self._testenv.tracdir, 'plugins',
+                          'DeleteTicket.py'), 'w').write(plugin)
         env = self._testenv.get_trac_environment()
         prevconfig = env.config.get('ticket', 'workflow')
         env.config.set('ticket', 'workflow',
@@ -30,7 +59,6 @@ class RegressionTestRev6017(FunctionalTw
             # Remove the DeleteTicket plugin
             env.config.set('ticket', 'workflow', prevconfig)
             env.config.save()
-            self._testenv.restart()
             for ext in ('py', 'pyc', 'pyo'):
                 filename = os.path.join(self._testenv.tracdir, 'plugins',
                                         'DeleteTicket.%s' % ext)
@@ -52,7 +80,8 @@ class RegressionTestTicket3833a(Function
         env.log.debug("RegressionTestTicket3833 debug1")
         debug1 = traclogfile.read()
         self.assertNotEqual(debug1.find("RegressionTestTicket3833 debug1"), -1,
-            'Logging off when it should have been on.\n%r' % debug1)
+                            'Logging off when it should have been on.\n%r'
+                            % debug1)
 
 
 class RegressionTestTicket3833b(FunctionalTestCaseSetup):
@@ -75,7 +104,8 @@ class RegressionTestTicket3833b(Function
         self.assertNotEqual(debug2.find("RegressionTestTicket3833 info2"), -1,
                             'Logging at info failed.\n%r' % debug2)
         self.assertEqual(debug2.find("RegressionTestTicket3833 debug2"), -1,
-            'Logging still on when it should have been off.\n%r' % debug2)
+                         'Logging still on when it should have been off.\n%r'
+                         % debug2)
 
 
 class RegressionTestTicket3833c(FunctionalTestCaseSetup):
@@ -103,12 +133,11 @@ class RegressionTestTicket3833c(Function
         success = debug3.find("RegressionTestTicket3833 debug3") != -1
         if not success:
             # Ok, the testcase failed, but we really need logging enabled.
-            self._testenv.restart()
             env.log.debug("RegressionTestTicket3833 fixup3")
             fixup3 = traclogfile.read()
             message = 'Logging still off when it should have been on.\n' \
                       '%r\n%r' % (debug3, fixup3)
-        self.assert_(success, message)
+        self.assertTrue(success, message)
 
 
 class RegressionTestTicket5572(FunctionalTwillTestCaseSetup):
@@ -122,29 +151,28 @@ class RegressionTestTicket5572(Functiona
 class RegressionTestTicket7209(FunctionalTwillTestCaseSetup):
     def runTest(self):
         """Test for regression of http://trac.edgewall.org/ticket/7209"""
-        summary = random_sentence(5)
-        ticketid = self._tester.create_ticket(summary)
+        ticketid = self._tester.create_ticket()
         self._tester.create_ticket()
         self._tester.add_comment(ticketid)
-        self._tester.attach_file_to_ticket(ticketid, tempfilename='hello.txt',
+        self._tester.attach_file_to_ticket(ticketid, filename='hello.txt',
                                            description='Preserved Descr')
         self._tester.go_to_ticket(ticketid)
         tc.find('Preserved Descr')
         # Now replace the existing attachment, and the description should come
         # through.
-        self._tester.attach_file_to_ticket(ticketid, tempfilename='hello.txt',
+        self._tester.attach_file_to_ticket(ticketid, filename='hello.txt',
                                            description='', replace=True)
         self._tester.go_to_ticket(ticketid)
         tc.find('Preserved Descr')
 
-        self._tester.attach_file_to_ticket(ticketid, tempfilename='blah.txt',
+        self._tester.attach_file_to_ticket(ticketid, filename='blah.txt',
                                            description='Second Attachment')
         self._tester.go_to_ticket(ticketid)
         tc.find('Second Attachment')
 
         # This one should get a new description when it's replaced
         # (Second->Other)
-        self._tester.attach_file_to_ticket(ticketid, tempfilename='blah.txt',
+        self._tester.attach_file_to_ticket(ticketid, filename='blah.txt',
                                            description='Other Attachment',
                                            replace=True)
         self._tester.go_to_ticket(ticketid)
@@ -159,10 +187,9 @@ class RegressionTestTicket9880(Functiona
         Upload of a file which the browsers associates a Content-Type
         of multipart/related (e.g. an .mht file) should succeed.
         """
-        summary = random_sentence(5)
-        ticketid = self._tester.create_ticket(summary)
+        ticketid = self._tester.create_ticket()
         self._tester.create_ticket()
-        self._tester.attach_file_to_ticket(ticketid, tempfilename='hello.mht',
+        self._tester.attach_file_to_ticket(ticketid, filename='hello.mht',
                                            content_type='multipart/related',
                                            data="""
 Well, the actual content of the file doesn't matter, the problem is
@@ -178,6 +205,8 @@ class ErrorPageValidation(FunctionalTwil
         tc.go(url + '?version=bug')
         tc.url(url)
         tc.find(internal_error)
+        tc.find('<form class="newticket" method="get" '
+                'action="http://trac.edgewall.org/newticket">')
 
 
 class RegressionTestTicket3663(FunctionalTwillTestCaseSetup):
@@ -196,14 +225,78 @@ class RegressionTestTicket3663(Functiona
         tc.find('Invalid URL encoding')
 
 
-def functionalSuite():
-    suite = FunctionalTestSuite()
-    return suite
+class RegressionTestTicket6318(FunctionalTwillTestCaseSetup):
+    def runTest(self):
+        """Regression test for non-ascii usernames (#6318)
+        """
+        # first do a logout, otherwise we might end up logged in as
+        # admin again, as this is the first thing the tester does.
+        # ... but even before that we need to make sure we're coming
+        # from a valid URL, which is not the case if we're just coming
+        # from the above test! ('/wiki/\xE9t\xE9')
+        self._tester.go_to_front()
+        self._tester.logout()
+        try:
+            # also test a regular ascii user name
+            self._testenv.adduser(u'user')
+            self._tester.login(u'user')
+            self._tester.go_to_front()
+            self._tester.logout()
+            # now test utf-8 user name
+            self._testenv.adduser(u'joé')
+            self._tester.login(u'joé')
+            self._tester.go_to_front()
+            self._tester.logout()
+            # finally restore expected 'admin' login
+            self._tester.login('admin')
+        finally:
+            self._testenv.deluser(u'joé')
+
 
+class RegressionTestTicket11434(FunctionalTwillTestCaseSetup):
+    """Test for regression of http://trac.edgewall.org/ticket/11434
+    Defects reported to trac-hacks should use the Component defined in the
+    plugin's URL.
+    """
+    def runTest(self):
+        env = self._testenv.get_trac_environment()
+        env.config.set('components', 'RaiseExceptionPlugin.*', 'enabled')
+        env.config.save()
+        create_file(os.path.join(env.path, 'plugins', 'RaiseExceptionPlugin.py'),
+"""\
+from trac.core import Component, implements
+from trac.web.api import IRequestHandler
+
+url = 'http://trac-hacks.org/wiki/HelloWorldMacro'
+
+class RaiseExceptionPlugin(Component):
+    implements(IRequestHandler)
+
+    def match_request(self, req):
+        if req.path_info == '/raise-exception':
+            return True
 
-def suite():
-    suite = functionalSuite()
+    def process_request(self, req):
+        raise Exception
 
+""")
+
+        try:
+            tc.go(self._tester.url + '/raise-exception')
+            tc.find(internal_error)
+            tc.find('<form class="newticket" method="get" '
+                    'action="http://trac-hacks.org/newticket">')
+            tc.find('<input type="hidden" name="component" '
+                    'value="HelloWorldMacro" />')
+        finally:
+            env.config.set('components', 'RaiseExceptionPlugin.*', 'disabled')
+
+
+def functionalSuite(suite=None):
+    if not suite:
+        import trac.tests.functional
+        suite = trac.tests.functional.functionalSuite()
+    suite.addTest(TestAttachmentNonexistentParent())
     suite.addTest(RegressionTestRev6017())
     suite.addTest(RegressionTestTicket3833a())
     suite.addTest(RegressionTestTicket3833b())
@@ -213,25 +306,10 @@ def suite():
     suite.addTest(RegressionTestTicket9880())
     suite.addTest(ErrorPageValidation())
     suite.addTest(RegressionTestTicket3663())
-
-    import trac.versioncontrol.tests
-    trac.versioncontrol.tests.functionalSuite(suite)
-    import trac.ticket.tests
-    trac.ticket.tests.functionalSuite(suite)
-    import trac.prefs.tests
-    trac.prefs.tests.functionalSuite(suite)
-    import trac.wiki.tests
-    trac.wiki.tests.functionalSuite(suite)
-    import trac.timeline.tests
-    trac.timeline.tests.functionalSuite(suite)
-    import trac.admin.tests
-    trac.admin.tests.functionalSuite(suite)
-    # The db tests should be last since the backup test occurs there.
-    import trac.db.tests
-    trac.db.tests.functionalSuite(suite)
-
+    suite.addTest(RegressionTestTicket6318())
+    suite.addTest(RegressionTestTicket11434())
     return suite
 
 
 if __name__ == '__main__':
-    unittest.main(defaultTest='suite')
+    unittest.main(defaultTest='functionalSuite')