Author: phd
Date: 2005-02-09 13:16:59 +0000 (Wed, 09 Feb 2005)
New Revision: 591
Added:
home/phd/SQLObject/inheritance/sqlobject/inheritance/tests/
home/phd/SQLObject/inheritance/sqlobject/inheritance/tests/__init__.py
home/phd/SQLObject/inheritance/sqlobject/inheritance/tests/test_inheritance.py
Log:
Added inheritance tests.
Added: home/phd/SQLObject/inheritance/sqlobject/inheritance/tests/__init__.py
===================================================================
--- home/phd/SQLObject/inheritance/sqlobject/inheritance/tests/__init__.py 2005-02-09 13:15:16 UTC (rev 590)
+++ home/phd/SQLObject/inheritance/sqlobject/inheritance/tests/__init__.py 2005-02-09 13:16:59 UTC (rev 591)
@@ -0,0 +1 @@
+#
Added: home/phd/SQLObject/inheritance/sqlobject/inheritance/tests/test_inheritance.py
===================================================================
--- home/phd/SQLObject/inheritance/sqlobject/inheritance/tests/test_inheritance.py 2005-02-09 13:15:16 UTC (rev 590)
+++ home/phd/SQLObject/inheritance/sqlobject/inheritance/tests/test_inheritance.py 2005-02-09 13:16:59 UTC (rev 591)
@@ -0,0 +1,34 @@
+from sqlobject import *
+from sqlobject.tests.dbtest import *
+from sqlobject.inheritance import InheritableSQLObject
+
+########################################
+## Inheritance
+########################################
+
+
+class Person(InheritableSQLObject):
+ _inheritable = 1 # I want this class to be inherited
+ firstName = StringCol()
+ lastName = StringCol()
+
+class Employee(Person):
+ _inheritable = 0 # If I don't want this class to be inherited
+ position = StringCol()
+
+
+def test_inheritance():
+ setupClass(Person)
+ setupClass(Employee)
+
+ Employee(firstName='Ian', lastName='Bicking', position='Project leader')
+ Person(firstName='Daniel', lastName='Savard')
+
+ persons = Person.select() # all
+ for person in persons:
+ assert isinstance(person, Person)
+ if isinstance(person, Employee):
+ assert not hasattr(person, "childName")
+ else:
+ assert hasattr(person, "childName")
+ assert not person.childName
|