Re: Running unit tests when you can't create a new database

2009-12-09 Thread Martin Omander
Sean,

That's great stuff; exactly what I was looking for. Thanks for the
pointer!

/Martin

On Dec 9, 12:40 pm, Sean Brant  wrote:
> This might help you 
> outhttp://ericholscher.com/projects/django-test-utils/keep_database_runn
> Or at least give you some pointers.
>
> - Sean
>
> On Wed, Dec 9, 2009 at 2:16 PM, Martin Omander  
> wrote:
> > Russ,
>
> > The method you describe sounds like the preferred way. It's cleaner to
> > add a new test runner module than to modify existing Django code. I
> > really like it.
>
> > But as you say, it's not obvious how to do this. I'd like to do a
> > write-up of how this is done, for the common use case where you don't
> > have database creation privileges.
>
> > Before I dig in and try to figure this out by myself, has anyone out
> > there written a test runner you could share with me?
>
> > /Martin
>
> > On Dec 9, 4:50 am, Russell Keith-Magee  wrote:
> >> On Wed, Dec 9, 2009 at 7:22 PM,   wrote:
> >> >> Django allows you to define a custom test runner. Copy
> >> >> django.tests.simple.run_tests() into your own code, removing the calls
> >> >> to create and destroy the test database. Then set TEST_RUNNER in your
> >> >> settings file to point at the new runner.
> >> > Hello!
> >> > I see many similar bugreports and wishes which was closed with this
> >> > proposal.
>
> >> > Unfortunately this will not work with recent django versions.
> >> > Errors like AttributeError: 'Settings' object has no attribute
> >> > 'DATABASE_SUPPORTS_TRANSACTIONS'
>
> >> Ok - I oversimplified slightly. You can't just delete the call to
> >> create the test database. You need to replicate some of the logic that
> >> the backend that establishes the extent of transaction support on your
> >> database of choice.
>
> >> My point still stands - Django ships with an ability to control and
> >> customize the testing process. You just need to pick the
> >> customizations that are required by your particular deployment
> >> scenario.
>
> >> Yours,
> >> Russ Magee %-)
>
> > --
>
> > 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 
> > athttp://groups.google.com/group/django-developers?hl=en.

--

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.




Re: Running unit tests when you can't create a new database

2009-12-09 Thread Sean Brant
This might help you out
http://ericholscher.com/projects/django-test-utils/keep_database_runner.html.
Or at least give you some pointers.

- Sean

On Wed, Dec 9, 2009 at 2:16 PM, Martin Omander  wrote:
> Russ,
>
> The method you describe sounds like the preferred way. It's cleaner to
> add a new test runner module than to modify existing Django code. I
> really like it.
>
> But as you say, it's not obvious how to do this. I'd like to do a
> write-up of how this is done, for the common use case where you don't
> have database creation privileges.
>
> Before I dig in and try to figure this out by myself, has anyone out
> there written a test runner you could share with me?
>
> /Martin
>
>
>
> On Dec 9, 4:50 am, Russell Keith-Magee  wrote:
>> On Wed, Dec 9, 2009 at 7:22 PM,   wrote:
>> >> Django allows you to define a custom test runner. Copy
>> >> django.tests.simple.run_tests() into your own code, removing the calls
>> >> to create and destroy the test database. Then set TEST_RUNNER in your
>> >> settings file to point at the new runner.
>> > Hello!
>> > I see many similar bugreports and wishes which was closed with this
>> > proposal.
>>
>> > Unfortunately this will not work with recent django versions.
>> > Errors like AttributeError: 'Settings' object has no attribute
>> > 'DATABASE_SUPPORTS_TRANSACTIONS'
>>
>> Ok - I oversimplified slightly. You can't just delete the call to
>> create the test database. You need to replicate some of the logic that
>> the backend that establishes the extent of transaction support on your
>> database of choice.
>>
>> My point still stands - Django ships with an ability to control and
>> customize the testing process. You just need to pick the
>> customizations that are required by your particular deployment
>> scenario.
>>
>> Yours,
>> Russ Magee %-)
>
> --
>
> 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.
>
>
>

--

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.




Re: Running unit tests when you can't create a new database

2009-12-09 Thread Martin Omander
Russ,

The method you describe sounds like the preferred way. It's cleaner to
add a new test runner module than to modify existing Django code. I
really like it.

But as you say, it's not obvious how to do this. I'd like to do a
write-up of how this is done, for the common use case where you don't
have database creation privileges.

Before I dig in and try to figure this out by myself, has anyone out
there written a test runner you could share with me?

/Martin



On Dec 9, 4:50 am, Russell Keith-Magee  wrote:
> On Wed, Dec 9, 2009 at 7:22 PM,   wrote:
> >> Django allows you to define a custom test runner. Copy
> >> django.tests.simple.run_tests() into your own code, removing the calls
> >> to create and destroy the test database. Then set TEST_RUNNER in your
> >> settings file to point at the new runner.
> > Hello!
> > I see many similar bugreports and wishes which was closed with this
> > proposal.
>
> > Unfortunately this will not work with recent django versions.
> > Errors like AttributeError: 'Settings' object has no attribute
> > 'DATABASE_SUPPORTS_TRANSACTIONS'
>
> Ok - I oversimplified slightly. You can't just delete the call to
> create the test database. You need to replicate some of the logic that
> the backend that establishes the extent of transaction support on your
> database of choice.
>
> My point still stands - Django ships with an ability to control and
> customize the testing process. You just need to pick the
> customizations that are required by your particular deployment
> scenario.
>
> Yours,
> Russ Magee %-)

--

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.




Re: Running unit tests when you can't create a new database

2009-12-09 Thread Russell Keith-Magee
On Wed, Dec 9, 2009 at 7:22 PM,   wrote:
>> Django allows you to define a custom test runner. Copy
>> django.tests.simple.run_tests() into your own code, removing the calls
>> to create and destroy the test database. Then set TEST_RUNNER in your
>> settings file to point at the new runner.
> Hello!
> I see many similar bugreports and wishes which was closed with this
> proposal.
>
> Unfortunately this will not work with recent django versions.
> Errors like AttributeError: 'Settings' object has no attribute
> 'DATABASE_SUPPORTS_TRANSACTIONS'
>
> Please help solving this issue.
>

--

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.




Re: Running unit tests when you can't create a new database

2009-12-09 Thread reg_gc
> Django allows you to define a custom test runner. Copy
> django.tests.simple.run_tests() into your own code, removing the calls
> to create and destroy the test database. Then set TEST_RUNNER in your
> settings file to point at the new runner.
Hello!
I see many similar bugreports and wishes which was closed with this
proposal.

Unfortunately this will not work with recent django versions.
Errors like AttributeError: 'Settings' object has no attribute
'DATABASE_SUPPORTS_TRANSACTIONS'

Please help solving this issue.

--

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.




Re: Running unit tests when you can't create a new database

2009-12-09 Thread Russell Keith-Magee
On Wed, Dec 9, 2009 at 8:53 AM, Martin Omander  wrote:
> Hi all,
>
> How about letting Django users run unit tests without creating a new
> test database?
>
> To use Django's built-in unit test harness, you have to have database
> creation privileges. Not all web hosts give users those privileges.
> For example, Webfaction, an excellent commercial Django host by all
> accounts (http://djangohosting.org), doesn't. This means there are
> Django users out there who can't run unit tests.
>
> See here for an example http://forum.webfaction.com/viewtopic.php?pid=13266
>
> The third message in that thread is from me, outlining how I solved
> the problem by hacking the Django testing code.
>
> Would it be worth it to add an option in the testing code that would
> allow users to run unit tests without database creation privileges?
> Any thoughts on what it would look like?

It already is available as an option - albeit perhaps not an obvious one.

Django allows you to define a custom test runner. Copy
django.tests.simple.run_tests() into your own code, removing the calls
to create and destroy the test database. Then set TEST_RUNNER in your
settings file to point at the new runner.

Yours
Russ Magee %-)

--

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.




Re: Running unit tests when you can't create a new database

2009-12-08 Thread Martin Omander

Good point about SQLite. I considered SQLite, but went with hacking
the test code in the end. My production environment uses MySql, so my
test environment should as well.

For example, I just uncovered a bug in my code that has to do with
database interactions. This bug may or may not show up when I test
against another database than MySql.

/Martin


On Dec 8, 6:21 pm, rebus_  wrote:
> 2009/12/9 Martin Omander :
>
>
>
> > Hi all,
>
> > How about letting Django users run unit tests without creating a new
> > test database?
>
> > To use Django's built-in unit test harness, you have to have database
> > creation privileges. Not all web hosts give users those privileges.
> > For example, Webfaction, an excellent commercial Django host by all
> > accounts (http://djangohosting.org), doesn't. This means there are
> > Django users out there who can't run unit tests.
>
> > See here for an examplehttp://forum.webfaction.com/viewtopic.php?pid=13266
>
> > The third message in that thread is from me, outlining how I solved
> > the problem by hacking the Django testing code.
>
> > Would it be worth it to add an option in the testing code that would
> > allow users to run unit tests without database creation privileges?
> > Any thoughts on what it would look like?
>
> > Cheers,
>
> > /Martin
>
> > --
>
> SQLite?
>
> http://docs.djangoproject.com/en/dev/topics/testing/#the-test-database

--

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.




Re: Running unit tests when you can't create a new database

2009-12-08 Thread rebus_
2009/12/9 Martin Omander :
> Hi all,
>
> How about letting Django users run unit tests without creating a new
> test database?
>
> To use Django's built-in unit test harness, you have to have database
> creation privileges. Not all web hosts give users those privileges.
> For example, Webfaction, an excellent commercial Django host by all
> accounts (http://djangohosting.org), doesn't. This means there are
> Django users out there who can't run unit tests.
>
> See here for an example http://forum.webfaction.com/viewtopic.php?pid=13266
>
> The third message in that thread is from me, outlining how I solved
> the problem by hacking the Django testing code.
>
> Would it be worth it to add an option in the testing code that would
> allow users to run unit tests without database creation privileges?
> Any thoughts on what it would look like?
>
> Cheers,
>
> /Martin
>
> --
>

SQLite?

http://docs.djangoproject.com/en/dev/topics/testing/#the-test-database

--

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.




Running unit tests when you can't create a new database

2009-12-08 Thread Martin Omander
Hi all,

How about letting Django users run unit tests without creating a new
test database?

To use Django's built-in unit test harness, you have to have database
creation privileges. Not all web hosts give users those privileges.
For example, Webfaction, an excellent commercial Django host by all
accounts (http://djangohosting.org), doesn't. This means there are
Django users out there who can't run unit tests.

See here for an example http://forum.webfaction.com/viewtopic.php?pid=13266

The third message in that thread is from me, outlining how I solved
the problem by hacking the Django testing code.

Would it be worth it to add an option in the testing code that would
allow users to run unit tests without database creation privileges?
Any thoughts on what it would look like?

Cheers,

/Martin

--

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.