Skip to content

Commit 033cf19

Browse files
committed
bugzilla: Fix the class autodetection magic and test it
1 parent 4836ed8 commit 033cf19

3 files changed

Lines changed: 13 additions & 1 deletion

File tree

bugzilla/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ def _init_class_from_url(self, url, sslverify):
112112

113113
self.__class__ = c
114114
log.info("Chose subclass %s v%s", c.__name__, c.version)
115+
return True
115116

116117

117118
# This is the list of possible Bugzilla instances an app can use,

bugzilla/base.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,13 @@ def __init__(self, url=None, user=None, password=None, cookiefile=-1,
314314
sslverify=True):
315315
# Hook to allow Bugzilla autodetection without weirdly overriding
316316
# __init__
317-
self._init_class_from_url(url, sslverify)
317+
if self._init_class_from_url(url, sslverify):
318+
kwargs = locals()
319+
del(kwargs["self"])
320+
321+
# pylint: disable=non-parent-init-called
322+
self.__class__.__init__(self, **kwargs)
323+
return
318324

319325
# Settings the user might want to tweak
320326
self.user = user or ''

tests/query.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import os
1414
import unittest
1515

16+
import bugzilla
1617
from bugzilla.bugzilla3 import Bugzilla34
1718
from bugzilla.bugzilla4 import Bugzilla4
1819
from bugzilla.rhbugzilla import RHBugzilla4
@@ -309,3 +310,7 @@ def testStandardQuery(self):
309310
'order': 'bug_status,bug_id'
310311
}
311312
self._check(url, query)
313+
314+
def testBZAutoMagic(self):
315+
bz = bugzilla.Bugzilla("bugzilla.redhat.com")
316+
self.assertTrue(hasattr(bz, "rhbz_back_compat"))

0 commit comments

Comments
 (0)