Hi,

On Sunday 28 November 2010, Christophe Pettus wrote:
> 
> I'm updating the patch for #12180 to work with the dev version of 1.3, and
> preparing a test case for it.  Being new to the Django test suite, it's
> not clear to me how to introduce a backend-specific and
> settings-file-specific test (the test case requires PostgreSQL 8.2+ and
> AUTOCOMMIT: True in the database options).  Is there some quick guidance
> from those more experienced than me?
> 
I'm not all that experienced, but my impression is that the Django test suite 
makes selective testing based not on the identity of the backend, but rather 
its features. This is expressed with decorators such as 
django.test.skipIfDBFeature/skipUnlessDBFearure. These are special cases of 
the more general unittest.skipIf and unittest.skipUnless.

However, looking at the bug, it seems like you require not only a backend-
specific test, but something more complex: You need a "fresh" connection. So 
what I think you should do, is:

- skipUnlessDBFeature('can_return_id_from_insert')
- in the test setup, manipulate settings.DATABASES to insert a new dictionary 
using the same details as 'default', and making sure AUTOCOMMIT is on
- make your insert query using= this new connection, so it is created for it.

One other point: There is a database feature named "uses_autocommit" -- 
currently it is false (by default) for postgresql_psycopg2, but if I 
understand correctly its true value depends on options. If it did reflect the 
options, you could have skipUnless'd it. I'm not sure if that would make your 
test better (you still need a fresh connection), but it may be worth opening 
its own ticket.

HTH,
        Shai.

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-develop...@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.

Reply via email to