Ticket #987: tests.py

File tests.py, 905 bytes (added by Simon G. <dev@…>, 18 years ago)
Line 
1"""
2# With default sites setting of 'example.com'
3
4>>> from django.contrib.sites.models import Site
5>>> s = Site.objects.all()[0]
6>>> s.domain = 'example.com'
7>>> s.save()
8>>> s.domain
9'example.com'
10
11>>> HttpResponseRedirect('/i/am/a/relative/path').headers['Location']
12'/i/am/a/relative/path'
13
14>>> HttpResponseRedirect('http://www.example.com/i/am/an/absolute/path').headers['Location']
15'http://www.example.com/i/am/an/absolute/path'
16
17>>> s.domain = 'djangoproject.com'
18>>> s.save()
19>>> s.domain
20'djangoproject.com'
21
22>>> HttpResponseRedirect('/i/am/a/relative/path').headers['Location']
23'http:/djangoproject.com/i/am/a/relative/path'
24
25>>> HttpResponseRedirect('http://www.example.com/i/am/an/absolute/path').headers['Location']
26'http://www.example.com/i/am/an/absolute/path'
27"""
28
29
30
31from django.http import HttpResponseRedirect
32
33if __name__ == "__main__":
34 import doctest
35 doctest.testmod()
Back to Top