hitrust / google-app-engine-django

Automatically exported from code.google.com/p/google-app-engine-django
Apache License 2.0
0 stars 0 forks source link

unittests doesn't load fixtures #69

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.
Create a test.py in your application directory with the following content.
import unittest
from myapp.models import *

class MyappTestCase(unittest.TestCase):
    fixtures = ['myfixture.yaml']

    def testFind(self):
        list = Poll.all()
        self.assertEquals(list[0].question, "What?")
2.
make sure you have a fixture suitable for your model that is called
myfixture.yaml

3.
run manage.py test myapp

What is the expected output? What do you see instead?
ERROR: testFind (contacts.tests.ContactTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\djangogae\myapp\tests.py", line 16, in testFind
    self.assertEquals(list[0].question, "What?")
  File "C:\Program
Files\Google\google_appengine\google\appengine\ext\db\__init__.py", line
1350, in __getitem__
    raise IndexError('The query returned fewer than %d results' % (arg+1))
IndexError: The query returned fewer than 1 results

What version of the product are you using? On what operating system?
GAE SDK 1.1.1
Windows Vista
Python 2.5
App Enginge Helper r48
django (trunk) r8128

Please provide any additional information below.
As shown in the django testing documentation at
http://www.djangoproject.com/documentation/testing/
in section "Understanding test output" it should also look for
"initial_data" fixtures but that doesn't work either.

Original issue reported on code.google.com by crippled...@gmail.com on 28 Jul 2008 at 7:44

GoogleCodeExporter commented 8 years ago
I have a similar problem.  I am able to use fixtures when doing a management.py
flush, by putting them in initial_data. But when I try to load the same 
fixtures in a
django TestCase with a line like the following:

class GameTestCase(TestCase):  

    fixtures = ['initial_data']

I get the following exception after running manage.py test

DEBUG:root:Destroyed test datastore
DEBUG:root:Configured API stubs for the test datastore
.......Traceback (most recent call last):
  File "C:\Documents and Settings\peter\workspace\gwgeclipse\gwg\manage.py", line 30,
in <module>
    execute_manager(settings)
  File "C:\Program
Files\Google\google_appengine\lib\django\django\core\management.py", line 1672, 
in
execute_
manager
    execute_from_command_line(action_mapping, argv)
  File "C:\Program
Files\Google\google_appengine\lib\django\django\core\management.py", line 1586, 
in
execute_
from_command_line
    action_mapping[action](args[1:], int(options.verbosity))
  File "C:\Program
Files\Google\google_appengine\lib\django\django\core\management.py", line 1325, 
in test
    failures = test_runner(app_list, verbosity)
  File "C:\Program Files\Google\google_appengine\lib\django\django\test\simple.py",
line 82, in run_tests
    result = unittest.TextTestRunner(verbosity=verbosity).run(suite)
  File "C:\Python25\lib\unittest.py", line 696, in run
    test(result)
  File "C:\Python25\lib\unittest.py", line 428, in __call__
    return self.run(*args, **kwds)
  File "C:\Python25\lib\unittest.py", line 424, in run
    test(result)
  File "C:\Python25\lib\unittest.py", line 428, in __call__
    return self.run(*args, **kwds)
  File "C:\Python25\lib\unittest.py", line 424, in run
    test(result)
  File "C:\Python25\lib\unittest.py", line 428, in __call__
    return self.run(*args, **kwds)
  File "C:\Python25\lib\unittest.py", line 424, in run
    test(result)
  File "C:\Python25\lib\unittest.py", line 428, in __call__
    return self.run(*args, **kwds)
  File "C:\Python25\lib\unittest.py", line 424, in run
    test(result)
  File "C:\Python25\lib\unittest.py", line 281, in __call__
    return self.run(*args, **kwds)
  File "C:\Program
Files\Google\google_appengine\lib\django\django\test\testcases.py", line 49, in 
run
    self.install_fixtures()
  File "C:\Program
Files\Google\google_appengine\lib\django\django\test\testcases.py", line 39, in
install_fix
tures
    management.flush(verbosity=0, interactive=False)
  File "C:\Program
Files\Google\google_appengine\lib\django\django\core\management.py", line 713, 
in flush
    sql_list = get_sql_flush()
  File "C:\Program
Files\Google\google_appengine\lib\django\django\core\management.py", line 359, 
in
get_sql_f
lush
    statements = backend.get_sql_flush(style, _get_table_list(), _get_sequence_list())
AttributeError: 'module' object has no attribute 'get_sql_flush'

Original comment by peterrec...@gmail.com on 11 Sep 2008 at 5:12