Skip to content

Instantly share code, notes, and snippets.

@dickbrouwer
Created October 20, 2010 23:24
Show Gist options
  • Save dickbrouwer/637570 to your computer and use it in GitHub Desktop.
Save dickbrouwer/637570 to your computer and use it in GitHub Desktop.
from django.test import TestCase
from django.utils.importlib import import_module
from django.http import HttpRequest
from django.conf import settings
class SampleTest(TestCase):
def setUp(self):
# Create mock request object with session key
engine = import_module(settings.SESSION_ENGINE)
request = HttpRequest()
request.session = engine.SessionStore()
request.session['somekey'] = 'somevalue'
request.session.session_key = 'session_key_from_model_object?'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment