| 1 | # test.py --------------
|
|---|
| 2 | import django
|
|---|
| 3 | from django.conf import settings
|
|---|
| 4 | from django.template import Context, Template
|
|---|
| 5 | import sys
|
|---|
| 6 | debug = ('debug' in sys.argv)
|
|---|
| 7 | settings_dict = dict(DEBUG=debug, TEMPLATE_DEBUG=debug)
|
|---|
| 8 | settings.configure(**settings_dict)
|
|---|
| 9 | class Foo:
|
|---|
| 10 | def no_exception(self):
|
|---|
| 11 | return "Method"
|
|---|
| 12 | def exception(self):
|
|---|
| 13 | raise AttributeError
|
|---|
| 14 | c = Context({"o": Foo()})
|
|---|
| 15 | templates = ("{{ o.no_exception }}", "{{ o.exception }}")
|
|---|
| 16 | print "Django version: %s" % django.get_version()
|
|---|
| 17 | print "settings: %r" % settings_dict
|
|---|
| 18 | try:
|
|---|
| 19 | for ttext in templates:
|
|---|
| 20 | t = Template(ttext)
|
|---|
| 21 | print repr((ttext, t.render(c)))
|
|---|
| 22 | except Exception, e:
|
|---|
| 23 | print "Caught exception: %r" % e
|
|---|
| 24 | # -------------
|
|---|