I am trying to create a set of test cases to cover my django application. I need predefined database data to run some of my tests. So I decided to use lights.
What I did: 1) the created binding file: oleg $ python manage.py dumpdata goserver> fixture1.json 2) The device is located in the directory where the oleg $ cp fixture1.json goserver / 3 application is running 3) Write the name of the texture in the test file in my application
class GoserverTestCase(TestCase): fixtures = ['fixture1.json'] def setUp(self): pass def testUserIsAdded(self): print "Users" , User.objects.all()
4) Run the text block with the command: oleg $ python manage.py test --verbosity = 2 goserver
Test run output (part of it):
Trying '/Users/oleg/jin/goclub/trunk/jin/../jin/register/fixtures' for xml fixture' initial_data '... No xml fixture' initial_data 'in' / Users / oleg / jin / goclub / trunk / jin /../ jin / register / fixtures. Trying '/Users/oleg/jin/goclub/trunk/jin/../jin/register/fixtures' for json fixture' initial_data '... No json fixture' initial_data 'in' / Users / oleg / jin / goclub / trunk / jin /../ jin / register / fixtures. check '/Users/oleg/jin/goclub/trunk/jin/../jin/captcha/fixtures' for fixtures ... Trying' /Users/oleg/jin/goclub/trunk/jin/../jin/captcha / fixtures 'for xml fixture' initial_data '... No xml fixture' initial_data 'in' /Users/oleg/jin/goclub/trunk/jin/../jin/captcha/fixtures. Trying '/Users/oleg/jin/goclub/trunk/jin/../jin/captcha/fixtures' for json fixture' initial_data '... No json fixture' initial_data 'in' / Users / oleg / jin / goclub / trunk / jin /../ jin / captcha / fixtures. check '/Users/oleg/jin/goclub/trunk/jin/../jin/goserver/fixtures' for fixtures ... Trying' /Users/oleg/jin/goclub/trunk/jin/../jin/goserver / fixtures 'for xml fixture' initial_data '... No xml fixture' initial_data 'in' /Users/oleg/jin/goclub/trunk/jin/../jin/goserver/fixtures. Trying '/Users/oleg/jin/goclub/trunk/jin/../jin/goserver/fixtures' for json fixture' initial_data '... No json fixture' initial_data 'in' / Users / oleg / jin / goclub / trunk / jin /../ jin / goserver / fixtures. Checking "/" for fixtures ... Trying '/' for xml fixture 'initial_data' ... No xml fixture 'initial_data' in '/'. Trying '/' for json fixture 'initial_data' ... No json fixture 'initial_data' in '/'. Checking 'U' for fixtures ... Trying 'U' for xml fixture 'initial_data' ... No xml fixture 'initial_data' in 'U'. Trying 'U' for json fixture 'initial_data' ... No json fixture 'initial_data' in 'U'. Checking 's' for fixtures ... Trying 's' for xml fixture 'initial_data' ... No xml fixture 'initial_data' in 's'. Trying '' for json fixture 'Initial_data' ..
In fact, the problem is that the device was not found at all, so there was no data that I wanted to add to the test database. Could you suggest me a way to solve the problem?
I tried a new way to do this. I just dumped the full database and put it in the application folder.
But I ran into some encoding issues.
You can check the error response:
File "build / bdist.macosx-10.3-i386 / egg / MySQLdb / cursors.py", line 168, executed if not self._defer_warnings: self._warning_check () File "build / bdist.macosx-10.3-i386 / egg /MySQLdb/cursors.py ", line 82, in _warning_check warn (w [-1], self.Warning, 3) File" /opt/local/lib/python2.5/warnings.py ", line 62, in the warning Global) File "/opt/local/lib/python2.5/warnings.py", line 102, raise a message in warn_explicit Warning: Incorrect string value: '\ xD0 \ x9D \ xD0 \ xB0 \ xD0 ...' for the column 'object_repr' on line 1
testUserIsAdded (jin.goserver.tests.GoserverTestCase) ... Users []
There is one more problem. When I turned off the appliances, I still get the error message:
Unit Test Code Coverage Results
Traceback (last last call): File "manage.py", line 11, in execute_manager (settings) File "/opt/local/lib/python2.5/site-packages/Django-1.0.2_final-py2.5.egg / django / core / management / init .py ", line 340, in exec_manager utility.execute () File" /opt/local/lib/python2.5/site-packages/Django-1.0.2_final-py2.5.egg / django / core / management / init .py ", line 295, executed by self.fetch_command (subcommand) .run_from_argv (self.argv) File" /opt/local/lib/python2.5/site-packages/Django-1.0 .2_final-py2.5.egg / django / core / management / base.py ", line 192, in run_from_argv self.execute (* args, ** options. Dict ) File" /opt/local/lib/python2.5 /site-packages/Django-1.0.2_final-py2.5.egg/django/core/management/base.py ", line 219, executed by output = self.handle (* args, ** options) File" / opt /local/lib/python2.5/site-packages/Django-1.0.2_final-py2.5.egg/dja ngo / core / management / commands / test.py ", line 33, in the handle failures = test_runner (test_labels, verbosity = verbosity, interactive = interactive) File" /opt/local/lib/python2.5/site-packages/django_test_coverage -0.1-py2.5.egg / django-test-coverage / runner.py ", line 58, in run_tests modules.extend (_package_modules (* package)) File" /opt/local/lib/python2.5/site- packages / django_test_coverage-0.1-py2.5.egg / django-test-coverage / runner.py ", line 92, in the folders _package_modules modules.append ( import (impstr + '.' + name, {}, {}, [ ''])) File "/Users/oleg/jin/goclub/trunk/jin/goserver/admin.py", line 11, in admin.site.register (ActiveList, ActiveListAdmin) File "/ opt / local / lib / python2.5 / site-packages / Django-1.0.2_final-py2.5.egg / django / contrib / admin / sites.py ", line 64, in the register raise AlreadyRegistered (" Model% s is already registered "% model. name ) django.contrib.admin.sites.AlreadyRegistered: the ActiveList model is already registered