title: Unicode in Django unit test
body: <p>I try to use a utf8 string in a Django unit test and have included </p>
  
  <pre><code># -*- coding: utf-8 -*-
  </code></pre>
  
  <p>but django-admin.py still complaints there is no encoding.</p>
  
  <blockquote>
    <p>Traceback (most recent call last):</p>
    
    <p>File "/home/basti/work/virtualenv/bin/django-admin.py", line 5, in
    
        management.execute_from_command_line()</p>
    
    <p>File
    "/home/basti/work/virtualenv/lib/python2.7/site-packages/django/core/management/<strong>init</strong>.py",
    line 429, in execute_from_command_line
        utility.execute()</p>
    
    <p>File
    "/home/basti/work/virtualenv/lib/python2.7/site-packages/django/core/management/<strong>init</strong>.py",
    line 379, in execute
        self.fetch_command(subcommand).run_from_argv(self.argv)</p>
    
    <p>File
    "> /home/basti/work/virtualenv/lib/python2.7/site-packages/django/core/management/base.py",
    line 191, in run_from_argv
        self.execute(*args, **options.<strong>dict</strong>)</p>
    
    <p>File
    "/home/basti/work/virtualenv/lib/python2.7/site-packages/django/core/management/base.py",
    line 220, in execute
        output = self.handle(*args, **options)</p>
    
    <p>File
    "/home/basti/work/virtualenv/lib/python2.7/site-packages/south/management/commands/test.py",
    line 8, in handle
        super(Command, self).handle(*args, **kwargs)</p>
    
    <p>File
    "/home/basti/work/virtualenv/lib/python2.7/site-packages/django/core/management/commands/test.py",
    line 37, in handle
        failures = test_runner.run_tests(test_labels)</p>
    
    <p>File
    "/home/basti/work/virtualenv/lib/python2.7/site-packages/django/test/simple.py",
    line 358, in run_tests
        suite = self.build_suite(test_labels, extra_tests)</p>
    
    <p>File
    "/home/basti/work/virtualenv/lib/python2.7/site-packages/django/test/simple.py",
    line 248, in build_suite
        suite.addTest(build_suite(app))</p>
    
    <p>File
    "/home/basti/work/virtualenv/lib/python2.7/site-packages/django/test/simple.py",
    line 77, in build_suite
        test_module = get_tests(app_module)</p>
    
    <p>File
    "/home/basti/work/virtualenv/lib/python2.7/site-packages/django/test/simple.py",
    line 35, in get_tests
        test_module = <strong>import</strong>('.'.join(app_path + [TEST_MODULE]), {}, {}, TEST_MODULE)</p>
    
    <p>SyntaxError: Non-ASCII character '\xc3' in file tests.py on line 242,
    but no encoding declared; see <a href="http://www.python.org/peps/pep-0263.html" rel="nofollow">http://www.python.org/peps/pep-0263.html</a>
    for details</p>
  </blockquote>
  
  <p>The code is</p>
  
  <p># -<em>- coding: utf-8 -</em>- </p>
  
  <pre><code>"""                                                                                                                                                                                                         
  This file demonstrates writing tests using the unittest module. These will pass                                                                                                                             
  when you run "manage.py test".                                                                                                                                                                              
  
  Replace this with more appropriate tests for your application.                                                                                                                                              
  """
  
  from django.test import TestCase, Client
  from django.contrib.auth.models import User
  from django.db.utils import IntegrityError
  from django.core.urlresolvers import reverse
  from django.utils.encoding import smart_unicode
  
  class ViewTests(TestCase):
      def setUp(self):
      self.client = Client()
  
     def test_french(self):
      self.client.cookies["django_language"] = 'fr'
      r = self.client.get("/")
      self.assertTrue(smart_unicode(u"Se déconnecter") in r.content)
  </code></pre>
  
  <p>I've tried to set TEST_CHARSET and TEST_DATABASE_CHARSET to utf8, but still no luck.</p>
  
  <p>Any hints on how to solve that?</p>
  
  <p>TIA &amp;&amp; have a nice day!</p>
  
  <p>Basti</p>