2010-10-11 12:55:17 +00:00
|
|
|
from django.utils import unittest
|
2010-01-05 12:06:45 +00:00
|
|
|
from django.utils.functional import lazy
|
|
|
|
|
|
|
|
|
2010-09-28 08:18:12 +00:00
|
|
|
class FunctionalTestCase(unittest.TestCase):
|
2010-01-05 12:06:45 +00:00
|
|
|
def test_lazy(self):
|
|
|
|
t = lazy(lambda: tuple(range(3)), list, tuple)
|
|
|
|
for a, b in zip(t(), range(3)):
|
|
|
|
self.assertEqual(a, b)
|
2011-05-05 00:09:51 +00:00
|
|
|
|
|
|
|
def test_lazy_base_class(self):
|
|
|
|
"""Test that lazy also finds base class methods in the proxy object"""
|
|
|
|
|
|
|
|
class Base(object):
|
|
|
|
def base_method(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
class Klazz(Base):
|
|
|
|
pass
|
|
|
|
|
|
|
|
t = lazy(lambda: Klazz(), Klazz)()
|
|
|
|
self.assertTrue('base_method' in dir(t))
|