changeset 14:9d0497dc19f8 draft

Ack! Think this is the way to introspect.
author David Barts <n5jrn@me.com>
date Thu, 16 May 2019 12:04:20 -0700
parents 6de828de4409
children 560c8fb55e4a
files tincan.py
diffstat 1 files changed, 9 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/tincan.py	Thu May 16 11:42:56 2019 -0700
+++ b/tincan.py	Thu May 16 12:04:20 2019 -0700
@@ -466,10 +466,15 @@
         self._class = None
         for i in dir(mod):
             v = getattr(mod, i)
-            if isclass(v) and issubclass(v, klass) and v is not klass:
-                if self._class is not None and self._class is not klass:
-                    raise TinCanError("{0}: contains multiple {1} classes".format(pypath, klass.__name__))
-                self._class = v
+            if isclass(v) and issubclass(v, klass):
+                if self._class is None:
+                    self._class = v
+                else:
+                    if self._class is klass:
+                        self._class = v
+                    elif v is not klass:
+                        raise TinCanError("{0}: contains multiple {1} classes".format(
+                            pypath, klass.__name__))
         if self._class is None:
             raise TinCanError("{0}: contains no {1} classes".format(pypath, klass.__name__))