[Django] #28478: Make DiscoverRunner skip creating a test database if not needed

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

[Django] #28478: Make DiscoverRunner skip creating a test database if not needed

Django
#28478: Make DiscoverRunner skip creating a test database if not needed
------------------------------------------------+------------------------
               Reporter:  Tim Graham            |          Owner:  nobody
                   Type:  Cleanup/optimization  |         Status:  new
              Component:  Testing framework     |        Version:  master
               Severity:  Normal                |       Keywords:
           Triage Stage:  Accepted              |      Has patch:  0
    Needs documentation:  0                     |    Needs tests:  0
Patch needs improvement:  0                     |  Easy pickings:  0
                  UI/UX:  0                     |
------------------------------------------------+------------------------
 Inspired by https://gist.github.com/zenweasel/7495758 and
 https://www.caktusgroup.com/blog/2013/10/02/skipping-test-db-creation/,
 `DiscoverRunner` could skip creating the test database if no
 `TransactionTestCase` or its subclasses are used.

 I'd suggest adding an attribute on the test classes such as
 `_needs_database` rather than using `isinstance(test,
 TransactionTestCase)` in those patches. This would allow compatibility in
 case Django users have other classes using the database that don't inherit
 from Django's classes (though I'm not aware of anyone doing this).

--
Ticket URL: <https://code.djangoproject.com/ticket/28478>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/052.7ad6bd6bb2fdfa2f907bcd9638511c5c%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #28478: Make DiscoverRunner skip creating a test database if not needed

Django
#28478: Make DiscoverRunner skip creating a test database if not needed
--------------------------------------+------------------------------------
     Reporter:  Tim Graham            |                    Owner:  nobody
         Type:  Cleanup/optimization  |                   Status:  new
    Component:  Testing framework     |                  Version:  master
     Severity:  Normal                |               Resolution:
     Keywords:                        |             Triage Stage:  Accepted
    Has patch:  0                     |      Needs documentation:  0
  Needs tests:  0                     |  Patch needs improvement:  0
Easy pickings:  0                     |                    UI/UX:  0
--------------------------------------+------------------------------------

Comment (by Simon Charette):

 I suggest we expose a `_needed_databases` attribute instead which returns
 `set(connections) if self.multi_db else {DEFAULT_DB_ALIAS}` to optimize
 the case where only the default database is needed as well.

--
Ticket URL: <https://code.djangoproject.com/ticket/28478#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/067.0e545a4d237b94fb0f2608e53f864c7c%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #28478: Make DiscoverRunner skip creating a test database if not needed

Django
In reply to this post by Django
#28478: Make DiscoverRunner skip creating a test database if not needed
--------------------------------------+------------------------------------
     Reporter:  Tim Graham            |                    Owner:  nobody
         Type:  Cleanup/optimization  |                   Status:  new
    Component:  Testing framework     |                  Version:  master
     Severity:  Normal                |               Resolution:
     Keywords:                        |             Triage Stage:  Accepted
    Has patch:  0                     |      Needs documentation:  0
  Needs tests:  0                     |  Patch needs improvement:  0
Easy pickings:  0                     |                    UI/UX:  0
--------------------------------------+------------------------------------

Comment (by Adam (Chainz) Johnson):

 N.B. pytest-django does this already, it makes the test databases pytest
 fixtures and attaches them to TransactionTestCase etc., if you run a set
 of tests without such classes then the fixture is never invoked.

--
Ticket URL: <https://code.djangoproject.com/ticket/28478#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/067.167ecdb45fc0b418aa1412545323dc31%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #28478: Make DiscoverRunner skip creating a test database if not needed

Django
In reply to this post by Django
#28478: Make DiscoverRunner skip creating a test database if not needed
--------------------------------------+------------------------------------
     Reporter:  Tim Graham            |                    Owner:  nobody
         Type:  Cleanup/optimization  |                   Status:  new
    Component:  Testing framework     |                  Version:  master
     Severity:  Normal                |               Resolution:
     Keywords:                        |             Triage Stage:  Accepted
    Has patch:  0                     |      Needs documentation:  0
  Needs tests:  0                     |  Patch needs improvement:  0
Easy pickings:  0                     |                    UI/UX:  0
--------------------------------------+------------------------------------

Comment (by Simon Charette):

 I wonder if we could unify `SimpleTestCase.allow_database_queries`,
 `TransactionTestCase.mutli_db` and this feature under a single
 `SimpleTestCase.databases` feature.

 The `databases` attribute could be set to `None` on `SimpleTestCase` and
 to `{DEFAULT_DB_ALIAS}` on `TransactionTestCase` with a deprecation shim
 that turns `multi_db = True` into `set(connections)`. The discover runner
 could simply create the union of all tests's `databases` and the
 `allow_database_queries` functionality could be reused to block accessed
 to all connection aliases not defined in the test's `databases`.

--
Ticket URL: <https://code.djangoproject.com/ticket/28478#comment:3>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/067.25c0a7c855b38a3681d5271d1c2830df%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #28478: Make DiscoverRunner skip creating a test database if not needed

Django
In reply to this post by Django
#28478: Make DiscoverRunner skip creating a test database if not needed
--------------------------------------+------------------------------------
     Reporter:  Tim Graham            |                    Owner:  nobody
         Type:  Cleanup/optimization  |                   Status:  new
    Component:  Testing framework     |                  Version:  master
     Severity:  Normal                |               Resolution:
     Keywords:                        |             Triage Stage:  Accepted
    Has patch:  0                     |      Needs documentation:  0
  Needs tests:  0                     |  Patch needs improvement:  0
Easy pickings:  0                     |                    UI/UX:  0
--------------------------------------+------------------------------------

Comment (by Simon Charette):

 Here's a
 [https://github.com/django/django/compare/master...charettes:ticket-28478
 POC] of what I had in mind. The patch is still missing documentation,
 appropriate warnings and probably doesn't correctly deal with mirroring
 setups but it correctly only creates the required databases while still
 respecting `allow_database_queries` and `multi_db`.

--
Ticket URL: <https://code.djangoproject.com/ticket/28478#comment:4>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/067.52d58f8b214bfa360fd0d96733331033%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #28478: Make DiscoverRunner skip creating a test database if not needed

Django
In reply to this post by Django
#28478: Make DiscoverRunner skip creating a test database if not needed
--------------------------------------+------------------------------------
     Reporter:  Tim Graham            |                    Owner:  nobody
         Type:  Cleanup/optimization  |                   Status:  new
    Component:  Testing framework     |                  Version:  master
     Severity:  Normal                |               Resolution:
     Keywords:                        |             Triage Stage:  Accepted
    Has patch:  0                     |      Needs documentation:  0
  Needs tests:  0                     |  Patch needs improvement:  0
Easy pickings:  0                     |                    UI/UX:  0
--------------------------------------+------------------------------------
Changes (by Adam (Chainz) Johnson):

 * cc: Adam (Chainz) Johnson (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/28478#comment:5>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/067.3f014c8f44d949189254ee6151a50a1e%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #28478: Make DiscoverRunner skip creating a test database if not needed

Django
In reply to this post by Django
#28478: Make DiscoverRunner skip creating a test database if not needed
--------------------------------------+------------------------------------
     Reporter:  Tim Graham            |                    Owner:  nobody
         Type:  Cleanup/optimization  |                   Status:  new
    Component:  Testing framework     |                  Version:  master
     Severity:  Normal                |               Resolution:
     Keywords:                        |             Triage Stage:  Accepted
    Has patch:  0                     |      Needs documentation:  0
  Needs tests:  0                     |  Patch needs improvement:  0
Easy pickings:  0                     |                    UI/UX:  0
--------------------------------------+------------------------------------

Comment (by Adam (Chainz) Johnson):

 The PR looks like a good start... do you have time to continue working on
 it? I'll happily help with review, since I was bitten by multi_db in
 #29513.

--
Ticket URL: <https://code.djangoproject.com/ticket/28478#comment:6>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/067.62dac1b3c3f72eaaaffd9e5839108b81%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #28478: Make DiscoverRunner skip creating a test database if not needed

Django
In reply to this post by Django
#28478: Make DiscoverRunner skip creating a test database if not needed
--------------------------------------+------------------------------------
     Reporter:  Tim Graham            |                    Owner:  nobody
         Type:  Cleanup/optimization  |                   Status:  new
    Component:  Testing framework     |                  Version:  master
     Severity:  Normal                |               Resolution:
     Keywords:                        |             Triage Stage:  Accepted
    Has patch:  1                     |      Needs documentation:  0
  Needs tests:  0                     |  Patch needs improvement:  1
Easy pickings:  0                     |                    UI/UX:  0
--------------------------------------+------------------------------------
Changes (by Simon Charette):

 * needs_better_patch:  0 => 1
 * has_patch:  0 => 1


Comment:

 [https://github.com/django/django/pull/10175 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/28478#comment:7>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/067.40436b69a686181617424b54b7814954%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.