574
575
prop1 = Property("column1", primary=True)
575
576
Alias = ClassAlias(Class, "USE_THIS")
576
577
self.assertEquals(Alias.__storm_table__, "USE_THIS")
579
def test_cached_aliases(self):
581
Class aliases are cached such that multiple invocations of
582
C{ClassAlias} return the same object.
584
alias1 = ClassAlias(self.Class, "something_unlikely")
585
alias2 = ClassAlias(self.Class, "something_unlikely")
586
self.assertIdentical(alias1, alias2)
587
alias3 = ClassAlias(self.Class, "something_unlikely2")
588
self.assertNotIdentical(alias1, alias3)
589
alias4 = ClassAlias(self.Class, "something_unlikely2")
590
self.assertIdentical(alias3, alias4)
592
def test_unnamed_aliases_not_cached(self):
593
alias1 = ClassAlias(self.Class)
594
alias2 = ClassAlias(self.Class)
595
self.assertNotIdentical(alias1, alias2)
597
def test_alias_cache_is_per_class(self):
599
The cache of class aliases is not as bad as it once was.
601
class LocalClass(self.Class):
603
alias = ClassAlias(self.Class, "something_unlikely")
604
alias2 = ClassAlias(LocalClass, "something_unlikely")
605
self.assertNotIdentical(alias, alias2)
607
def test_aliases_only_last_as_long_as_class(self):
609
The cached ClassAliases only last for as long as the class is alive.
611
class LocalClass(self.Class):
613
alias = ClassAlias(LocalClass, "something_unlikely3")
614
alias_ref = ref(alias)
615
class_ref = ref(LocalClass)
619
gc.collect(); gc.collect(); gc.collect()
621
self.assertIdentical(class_ref(), None)
622
self.assertIdentical(alias_ref(), None)
580
625
class TypeCompilerTest(TestHelper):