Index: tractags/tests/formatter.py
===================================================================
--- tractags/tests/formatter.py	(revision 15572)
+++ tractags/tests/formatter.py	(nonexistent)
@@ -1,156 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2003-2009 Edgewall Software
-# Copyright (C) 2013 Steffen Hoffmann <hoff.st@web.de>
-#
-# This software is licensed as described in the file COPYING, which
-# you should have received as part of this distribution.
-#
-
-import difflib
-import re
-import unittest
-
-from trac.test import EnvironmentStub, Mock, MockPerm, locale_en
-from trac.util.datefmt import utc
-from trac.util.text import to_unicode
-from trac.web.chrome import web_context
-from trac.web.href import Href
-from trac.web.session import DetachedSession
-from trac.wiki.formatter import HtmlFormatter, InlineHtmlFormatter
-
-from tractags.db import TagSetup
-
-
-class WikiTestCase(unittest.TestCase):
-
-    generate_opts = {}
-
-    def __init__(self, title, input, correct, file, line, setup=None,
-                 teardown=None):
-        unittest.TestCase.__init__(self, 'test')
-        self.title = title
-        self.input = input
-        self.correct = correct
-        self.file = file
-        self.line = line
-        self._setup = setup
-        self._teardown = teardown
-
-    def setUp(self):
-        self.env = EnvironmentStub(default_data=True,
-                                   enable=('trac.*', 'tractags.*'))
-        self.req = Mock(href=Href('/'),
-                        abs_href=Href('http://www.example.com/'),
-                        authname='anonymous', perm=MockPerm(),
-                        path_info='/wiki/WikiStart', chrome={},
-                        session=DetachedSession(self.env, 'anonymous'),
-                        tz=utc, args={}, locale=locale_en)
-        self.context = web_context(self.req, 'wiki', 'WikiStart')
-        setup = TagSetup(self.env)
-        self._revert_tractags_schema_init()
-        setup.upgrade_environment()
-        if self._setup:
-            self._setup(self)
-
-    def tearDown(self):
-        self._revert_tractags_schema_init()
-        self.env.reset_db()
-        if self._teardown:
-            self._teardown(self)
-
-    def _revert_tractags_schema_init(self):
-        with self.env.db_transaction as db:
-            db("DROP TABLE IF EXISTS tags")
-            db("DROP TABLE IF EXISTS tags_change")
-            db("DELETE FROM system WHERE name='tags_version'")
-            db("DELETE FROM permission WHERE action %s" % db.like(),
-               ('TAGS_%',))
-
-    def test(self):
-        """Testing WikiFormatter"""
-        formatter = self.formatter()
-        v = unicode(formatter.generate(**self.generate_opts))
-        v = v.replace('\r', '').replace(u'\u200b', '')
-        try:
-            self.assertEquals(self.correct, v)
-        except AssertionError, e:
-            msg = to_unicode(e)
-            match = re.match(r"u?'(.*)' != u?'(.*)'", msg)
-            if match:
-                g1 = ["%s\n" % x for x in match.group(1).split(r'\n')]
-                g2 = ["%s\n" % x for x in match.group(2).split(r'\n')]
-                expected = ''.join(g1)
-                actual = ''.join(g2)
-                wiki = repr(self.input).replace(r'\n', '\n')
-                diff = ''.join(list(difflib.unified_diff(g1, g2, 'expected',
-                                                         'actual')))
-                # Tip: sometimes, 'expected' and 'actual' differ only by 
-                #      whitespace, so it can be useful to visualize them, e.g.
-                # expected = expected.replace(' ', '.')
-                # actual = actual.replace(' ', '.')
-                def info(*args):
-                    return '\n========== %s: ==========\n%s' % args
-                msg = info('expected', expected)
-                msg += info('actual', actual)
-                msg += info('wiki', ''.join(wiki))
-                msg += info('diff', diff)
-            raise AssertionError( # See below for details
-                '%s\n\n%s:%s: "%s" (%s flavor)' \
-                % (msg, self.file, self.line, self.title, formatter.flavor))
-
-    def formatter(self):
-        return HtmlFormatter(self.env, self.context, self.input)
-
-    def shortDescription(self):
-        return 'Test ' + self.title
-
-
-class OneLinerTestCase(WikiTestCase):
-    def formatter(self):
-        return InlineHtmlFormatter(self.env, self.context, self.input)
-
-class EscapeNewLinesTestCase(WikiTestCase):
-    generate_opts = {'escape_newlines': True}
-    def formatter(self):
-        return HtmlFormatter(self.env, self.context, self.input)
-
-
-def suite(data=None, setup=None, file=__file__, teardown=None, context=None):
-    suite = unittest.TestSuite()
-    def add_test_cases(data, filename):
-        tests = re.compile('^(%s.*)$' % ('=' * 30), re.MULTILINE).split(data)
-        next_line = 1
-        line = 0
-        for title, test in zip(tests[1::2], tests[2::2]):
-            title = title.lstrip('=').strip()            
-            if line != next_line:
-                line = next_line
-            if not test or test == '\n':
-                continue
-            next_line += len(test.split('\n')) - 1
-            if 'SKIP' in title or 'WONTFIX' in title:
-                continue
-            blocks = test.split('-' * 30 + '\n')
-            page_escape_nl = oneliner = None
-            if len(blocks) < 4:
-                blocks.extend([None,] * (4 - len(blocks)))
-            input, page, oneliner, page_escape_nl = blocks[:4]
-            if page:
-                page = WikiTestCase(
-                    title, input, page, filename, line, setup,
-                    teardown)
-            if oneliner:
-                oneliner = OneLinerTestCase(
-                    title, input, oneliner[:-1], filename, line, setup,
-                    teardown, context)
-            if page_escape_nl:
-                page_escape_nl = EscapeNewLinesTestCase(
-                    title, input, page_escape_nl, filename, line, setup,
-                    teardown, context)
-            for tc in [page, oneliner, page_escape_nl]:
-                if tc:
-                    suite.addTest(tc)
-    if data:
-        add_test_cases(data, file)
-    return suite
Index: tractags/tests/macros.py
===================================================================
--- tractags/tests/macros.py	(revision 15572)
+++ tractags/tests/macros.py	(working copy)
@@ -16,10 +16,10 @@
 from trac.test import EnvironmentStub, Mock, MockPerm
 from trac.web.chrome import Chrome
 from trac.web.href import Href
+from trac.wiki.test import wikisyntax_test_suite
 
 from tractags.db import TagSetup
 from tractags.macros import TagWikiMacros, query_realms
-from tractags.tests import formatter
 
 
 def _revert_tractags_schema_init(env):
@@ -183,9 +183,16 @@
 
 
 def listtagged_setup(tc):
+    # tc.env.enable_component('tractags')
+    _revert_tractags_schema_init(tc.env)
+    TagSetup(tc.env).upgrade_environment()
     _insert_tags(tc.env, 'wiki', 'WikiStart', ('abc', 'xyz'))
 
 
+def listtagged_teardown(tc):
+    _revert_tractags_schema_init(tc.env)
+
+
 class TagCloudMacroTestCase(_BaseTestCase):
 
     def setUp(self):
@@ -278,8 +285,10 @@
     suite = unittest.TestSuite()
     suite.addTest(unittest.makeSuite(TagTemplateProviderTestCase))
     suite.addTest(unittest.makeSuite(ListTaggedMacroTestCase))
-    suite.addTest(formatter.suite(LISTTAGGED_MACRO_TEST_CASES,
-                                  listtagged_setup, __file__))
+    suite.addTest(
+        wikisyntax_test_suite(LISTTAGGED_MACRO_TEST_CASES, listtagged_setup,
+                              __file__, listtagged_teardown,
+                              enable_components=('trac.*', 'tractags.*')))
     suite.addTest(unittest.makeSuite(TagCloudMacroTestCase))
     suite.addTest(unittest.makeSuite(QueryRealmsTestCase))
     return suite
Index: tractags/tests/wiki.py
===================================================================
--- tractags/tests/wiki.py	(revision 15572)
+++ tractags/tests/wiki.py	(working copy)
@@ -14,10 +14,10 @@
 from trac.perm import PermissionCache, PermissionError, PermissionSystem
 from trac.resource import Resource
 from trac.test import EnvironmentStub, Mock
+from trac.wiki.test import wikisyntax_test_suite
 
 from tractags.api import TagSystem
 from tractags.db import TagSetup
-from tractags.tests import formatter
 from tractags.wiki import WikiTagProvider
 
 
@@ -60,7 +60,7 @@
 <a href="/tags/onetag">tag:onetag</a>
 <a href="/tags/2ndtag">tag:2ndtag</a> n' more
 <a href="/tags/a.really%3F_%5Cwild-thing">tag:a.really?_\wild-thing</a>!
-# regression test for ticket <tt>#9057</tt>
+# regression test for ticket <code>#9057</code>
 <a href="/tags/single\'quote">tag:single\'quote</a>
 </p>
 ------------------------------
@@ -280,10 +280,10 @@
 def test_suite():
     suite = unittest.TestSuite()
     suite.addTest(unittest.makeSuite(WikiTagProviderTestCase))
-    suite.addTest(formatter.suite(TEST_CASES, wiki_setup, __file__,
-                                  wiki_teardown))
-    suite.addTest(formatter.suite(TEST_NOPERM, wiki_setup_no_perm, __file__,
-                                  wiki_teardown))
+    suite.addTest(wikisyntax_test_suite(TEST_CASES, wiki_setup, __file__,
+                                        wiki_teardown))
+    suite.addTest(wikisyntax_test_suite(TEST_NOPERM, wiki_setup_no_perm, __file__,
+                                        wiki_teardown))
     return suite
 
 if __name__ == '__main__':
