def setUp(self):
self.old_TEMPLATE_DIRS = settings.TEMPLATE_DIRS
settings.TEMPLATE_DIRS = (
os.path.join(os.path.dirname(admin.__file__), "templates"),
)
self.user = User(
username = "foo",
is_staff = True,
is_superuser = True,
)
self.user.set_password("bar")
self.user.save()
# Log the user in.
if hasattr(self, "settings"):
with self.settings(INSTALLED_APPS=tuple(set(tuple(settings.INSTALLED_APPS) + ("django.contrib.sessions",)))): # HACK: Without this the client won't log in, for some reason.
self.client.login(
username = "foo",
password = "bar",
)
else:
self.client.login(
username = "foo",
password = "bar",
)
评论列表
文章目录