Commits

Anonymous committed 4c28f3b Draft

Dashboard code import: BH_Dashboard: TracDuTest framework now runs using Trac>=0.13

  • Participants
  • Parent commits d0eed01

Comments (0)

Files changed (3)

bhdashboard/tests/__init__.py

 from trac.test import EnvironmentStub
 from trac.util.compat import set
 
+from pkg_resources import get_distribution
 import sys
 
 #------------------------------------------------------
+#    Context information
+#------------------------------------------------------
+
+trac_version = tuple(int(i) for i in get_distribution('Trac').parsed_version \
+                            if i.startswith('0'))
+
+#------------------------------------------------------
 #    Trac environments used for testing purposes
 #------------------------------------------------------
 
       db = self.env.get_db_cnx()
       cursor = db.cursor()
       for table in db_default.schema:
-        cursor.execute("DELETE FROM " + table.name)
+        if trac_version < (0, 13) : # FIXME: Should it be (0, 12)
+            cursor.execute("DELETE FROM " + table.name)
+        else:
+            cursor.execute("DROP TABLE " + table.name)
       db.commit()
 
       self.env.reset_db(default_data=True)

bhdashboard/tests/test_report.py

       >>> from bhdashboard.api import IWidgetProvider
       >>> from bhdashboard.widgets.report import *
       >>> allcls = ComponentMeta._registry.get(IWidgetProvider, [])
-      >>> for wpcls in (TicketReportWidget,):
-      ...   print wpcls in allcls
-      ...
-      True
+      >>> [wpcls in allcls for wpcls in (TicketReportWidget,)]
+      [True]
       """,
     '|TicketReport: Metadata' : r"""
       >>> list(widget.get_widgets())

bhdashboard/util.py

     req.callbacks.update({
         'authname': rd.authenticate,
         'chrome': chrome.prepare_request,
-        'hdf': rd._get_hdf,
+        'hdf': getattr(rd, '_get_hdf', None),
         'perm': rd._get_perm,
         'session': rd._get_session,
         'tz': rd._get_timezone,