Commits

Anonymous committed 9171dc1 Draft

Dashboard code import: BH_Dashboard: Tagging Trac versions to track inflection points in test code

  • Participants
  • Parent commits 774ea22

Comments (0)

Files changed (1)

File bhdashboard/tests/__init__.py

 trac_version = tuple(int(i) for i in get_distribution('Trac').parsed_version \
                             if i.startswith('0'))
 
+# The exact moments (versions) where some things started to change
+# in such a manner that break previous test code
+
+trac_tags = (
+        (0, 13), # TODO: Find the exact version ( Trac=0.12 ? )
+    )
+
 #------------------------------------------------------
 #    Trac environments used for testing purposes
 #------------------------------------------------------
   def enable_component(self, clsdef):
     r"""Enable a plugin temporarily at testing time.
     """
-    if trac_version <= (0.13):      # Check whether this should be 0.12 instead
+    if trac_version < trac_tags[0]:
       # `enabled_components` should be enough in this case
       if clsdef not in self.enabled_components :
         self.enabled_components.append(clsdef)
   def disable_component(self, clsdef):
     r"""Disable a plugin temporarily at testing time.
     """
-    if trac_version < (0, 13):
+    if trac_version < trac_tags[0]:
       try:
         self.enabled_components.remove(clsdef)
       except ValueError :
     """
     super(DocTestTracLoader, self).__init__(dt_finder, globs, \
                                               extraglobs, **opts)
-    if trac_version >= (0, 13) :
+    if trac_version >= trac_tags[0]:
         opts['disable'] = disable
     self.env = self.createTracEnv(default_data, enable, **opts)
     self.load_components(load is None and self.default_packages or load)
                             at testing time. Ignored in Trac<0.13
     @return                 the environment used for testing purpose.
     """
-    if trac_version >= (0, 13):
+    if trac_version >= trac_tags[0]:
       kwargs = {'disable' : disable}
     else :
       kwargs = {}
       db = self.env.get_db_cnx()
       cursor = db.cursor()
       for table in db_default.schema:
-        if trac_version < (0, 13) : # FIXME: Should it be (0, 12) ?
+        if trac_version < trac_tags[0]: # FIXME: Should it be (0, 12) ?
             cursor.execute("DELETE FROM " + table.name)
         else:
             cursor.execute("DROP TABLE " + table.name)