>
> Actually, if I may ask, how else would one load bunches of fixtures in the
> DB and run tests in parallel without my PR ?
>
As I said, register a post_migrate handler during testing that loads your
data. It will run during the creation of the first database in
connection.creation.create_test_db, as part of call_command('migrate'),
before the test runner code clones the database for parallel execution.
There's no need to change Django to support this.
Another option is that you extend your database backend and override
creation.create_test_db and add logic there.
By the way, I think it's the general opinion that tests are best *without* a
large generic fixture available to them. It's certainly been my experience,
as it makes it very hard to later understand *what* data a specific test
does or does not rely upon, and if the data can be updated safely. The tool
I prefer for test data generation is factory boy (
https://factoryboy.readthedocs.io/en/latest/ ) which can be used to create
data per test method or class, without having to laboriously specify every
field of every model.
On 29 April 2017 at 13:36, Marcos Diez <[email protected]> wrote:
> I believe I was not clear.
>
> I do use migrations to populate Enums and other data that should also be
> available in production.
>
> The code I am sending is to load fixtures on the database.
>
> This way all tests can assume the same set of data and we all the fixtures
> are loaded in one place, which in my case of use it makes sense.
>
> The advantage of the method I am proposing is that it is quite fast. Data
> is loaded only once in the DB and that it is duplicated in bulk mode by the
> DBMS, as many times as necessary when tests run in parallel.
>
> Another unexpected convenience of my method is that a developer who uses
> Django to populate fixtures in the database, does not have to worry if
> his/her code to generate data has side effects or not if he is running
> tests in parallel, because his data generation code will run only once.
>
>
> Actually, if I may ask, how else would one load bunches of fixtures in the
> DB and run tests in parallel without my PR ?
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django developers (Contributions to Django itself)" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/django-developers.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-developers/32df6bec-a2ce-494e-b007-
> 5f4433ad682f%40googlegroups.com
> <https://groups.google.com/d/msgid/django-developers/32df6bec-a2ce-494e-b007-5f4433ad682f%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>
--
Adam
--
You received this message because you are subscribed to the Google Groups
"Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-developers/CAMyDDM0vEu2fTXfGCFhhTtVZ7rJOrOSKYDFT6Sb%2B%2Bh%3DAs5Z9TA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.