1 from django.conf import settings
2 from django.test import TestCase
6 class WLTestCase(TestCase):
8 Generic base class for tests. Adds settings freeze and clears MEDIA_ROOT.
11 self._MEDIA_ROOT, settings.MEDIA_ROOT = settings.MEDIA_ROOT, tempfile.mkdtemp(prefix='djangotest_')
14 shutil.rmtree(settings.MEDIA_ROOT, True)
15 settings.MEDIA_ROOT = self._MEDIA_ROOT
17 class PersonStub(object):
19 def __init__(self, first_names, last_name):
20 self.first_names = first_names
21 self.last_name = last_name
24 class BookInfoStub(object):
26 def __init__(self, **kwargs):
29 def __setattr__(self, key, value):
30 if not key.startswith('_'):
31 self.__dict[key] = value
32 return object.__setattr__(self, key, value)
34 def __getattr__(self, key):
35 return self.__dict[key]
38 return dict((key, unicode(value)) for key, value in self.__dict.items())