Skip to content

QPID-8631: make the qpid-python-test script Python 3 compatible #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions qpid-python-test
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ from logging import getLogger, StreamHandler, Formatter, Filter, \
from qpid.harness import Skipped
from qpid.util import URL

if sys.version_info.major == 3:
CLASS_TYPES = (type,)
else:
CLASS_TYPES = (type, types.ClassType)

levels = {
"DEBUG": DEBUG,
"WARN": WARN,
Expand Down Expand Up @@ -502,7 +507,7 @@ class FunctionScanner(PatternMatcher):
class ClassScanner(PatternMatcher):

def inspect(self, obj):
return type(obj) in (types.ClassType, types.TypeType) and self.matches(obj.__name__)
return type(obj) in CLASS_TYPES and self.matches(obj.__name__)

def descend(self, cls):
# the None is required for older versions of python
Expand All @@ -514,7 +519,7 @@ class ClassScanner(PatternMatcher):
for name in names:
obj = getattr(cls, name)
t = type(obj)
if t == types.MethodType and name.startswith("test"):
if hasattr(obj, '__call__') and name.startswith("test"):
yield MethodTest(cls, name)

class ModuleScanner:
Expand Down