'test experiments' can drop your db.

16 views
Skip to first unread message

Tom Ketchup

unread,
Apr 12, 2010, 12:49:37 AM4/12/10
to django-lean
I figured someone might want to know that running the nose tests can
drop your database (Praise Jesus). Have no idea what happened here, it
seems to have complained that it couldn't do transactions. Although
I'm running mysql innodb. As far as I know I can do transactions...

Here was the output of the tests:

...
...
Installing index for admin.LogEntry model
/usr/local/lib/python2.6/dist-packages/django/middleware/http.py:50:
DeprecationWarning: SetRemoteAddrFromForwardedFor has been removed.
See the Django 1.1 release notes for details.
category=DeprecationWarning)
......../usr/lib/python2.6/dist-packages/scipy/stats/stats.py:420:
DeprecationWarning: scipy.stats.mean is deprecated; please update your
code to use numpy.mean.
Please note that:
- numpy.mean axis argument defaults to None, not 0
- numpy.mean has a ddof argument to replace bias in a more general
manner.
scipy.stats.mean(a, bias=True) can be replaced by numpy.mean(x,
axis=0, ddof=1).
axis=0, ddof=1).""", DeprecationWarning)
........No handlers could be found for logger "experiments.loader"
.....EEEEEEEEEEE
======================================================================
ERROR: testMissingGoalType
(proto.experiments.tests.test_models.TestExperimentModels)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/bar/workspace/web/Back/django/proto/../proto/experiments/
tests/test_models.py", line 206, in testMissingGoalType
GoalRecord.record('inexistant-goal',
TestUser(anonymous_visitor=anonymous_visitor))
File "/home/bar/workspace/web/Back/django/proto/../proto/experiments/
models.py", line 52, in record
return cls._record(goal_name, experiment_user)
File "/home/bar/workspace/web/Back/django/proto/../proto/experiments/
models.py", line 44, in _record
goal_type = GoalType.objects.get(name=goal_name)
File "/usr/local/lib/python2.6/dist-packages/django/db/models/
manager.py", line 120, in get
return self.get_query_set().get(*args, **kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/db/models/
query.py", line 305, in get
% self.model._meta.object_name)
DoesNotExist: GoalType matching query does not exist.

======================================================================
ERROR: testMissingGoalType
(proto.experiments.tests.test_models.TestExperimentModels)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/lib/python2.6/dist-packages/django/test/
testcases.py", line 251, in __call__
self._post_teardown()
File "/usr/local/lib/python2.6/dist-packages/django/test/
testcases.py", line 264, in _post_teardown
self._fixture_teardown()
File "/usr/local/lib/python2.6/dist-packages/django/test/
testcases.py", line 456, in _fixture_teardown
if not settings.DATABASE_SUPPORTS_TRANSACTIONS:
File "/usr/local/lib/python2.6/dist-packages/django/utils/
functional.py", line 273, in __getattr__
return getattr(self._wrapped, name)
AttributeError: 'Settings' object has no attribute
'DATABASE_SUPPORTS_TRANSACTIONS'

======================================================================
ERROR: testParticipantEnrollment
(proto.experiments.tests.test_models.TestExperimentModels)
.....

There was an exception like that for each test (omitted here).
Afterwards I was left with a "test_myapp" database with tables and no
data, and my "myapp" database was dropped. So... it is erm,
frustrating to have your database dropped. No biggie, but certainly
"gah". I'm still interested in getting django-lean running in some
sort of obedient way though, anyone know what I might be running into?

Thanks, cheers

Erik Wright

unread,
Apr 12, 2010, 6:44:47 AM4/12/10
to djang...@googlegroups.com
Hi Tom,

That's surprising behavior. Can you tell me what command you used to
run the tests? Had you installed Django-Lean into your own project or
were you running them standalone?

Thanks,

Erik

> --
> To unsubscribe, reply using "remove me" as the subject.

Tom Ketchup

unread,
Apr 12, 2010, 2:50:07 PM4/12/10
to django-lean
"python manage.py test experiments"

Maybe my project structure had something to do with it:

proto/
(root project files, like settings.py, manage.py, etc -- this
is where "manage.py test experiements" was run)
/experiments/ (the experiments dir from the dj lean 'build'
directory)
/myapp/ (my app)


with settings.INSTALLED_APPS = ( '...', '...', 'proto.experiments', )

...as I recall right now. I'll look a bit closer at my project code
this evening.

Thanks

On Apr 12, 3:44 am, Erik Wright <e...@erikwright.com> wrote:
> Hi Tom,
>
> That's surprising behavior. Can you tell me what command you used to  
> run the tests? Had you installed Django-Lean into your own project or  
> were you running them standalone?
>
> Thanks,
>
> Erik
>

Erik Wright

unread,
Apr 12, 2010, 3:56:21 PM4/12/10
to django-lean
Ultimately, there is nothing in Django-Lean that really ought to do
this. We don't access the database outside of Django's model layer.

It's possible that the issue is the way you have re-rooted the
'experiments' package inside your 'proto' package. In general, I'll be
surprised if that works. I don't think many apps are designed to work
that way, and Django Lean certainly isn't. What it expects is for the
parent directory of 'experiments' (normally, the exploded egg
directory if you installed from an egg) to be in PYTHONPATH.

I hope that helps.

-Erik

Tom Ketchup

unread,
Apr 12, 2010, 5:33:59 PM4/12/10
to django-lean
I see, I suppose what I was thinking with putting it in the project is
that that would be the place for it if I was going to be possibly
tweaking with it.

I'll remove that, install normally, and reference PYTHONPATH
"experiments" in INSTALLED_APPS instead of the copy that was placed in
my project. If it happens to still mistreat the database on my setup
(which is otherwise pretty vanilla) I'll pass it on, but I expect that
must be related to what happened. Curiously this was even retried to
verify that that was in fact what happened. I re-created the myapp
tables with syncdb, then re-ran 'test experiments' with the same
result. Just development data that is easily re-created so no real
trouble.

Hey by the way -- a question perhaps on the same subject, I noticed
that django-lean/experiments/testsettings.py line 9
has "DATABASE_SUPPORTS_TRANSACTIONS=False"

Does this get overridden if that's not the case during install? Or is
it required for a specific reason?

Anyway, I do appreciate that you took a look at the project structure,
thanks.

Cheers

Reply all
Reply to author
Forward
0 new messages