I'm curious if you feel that running django_otp's tests as part of your 
project's tests is adding value. All third-party apps that I've used 
(including tests for django.contrib apps*) have moved their tests to a 
separate directory so that they're not installed along with the 
application. It's quite difficult for a library to write tests that work 
with whatever settings a project might provide -- at least that's what we 
found with tests for contrib apps.

* https://groups.google.com/d/topic/django-developers/nj_Zha341pA/discussion

On Wednesday, February 22, 2017 at 9:23:25 AM UTC-5, Tom Evans wrote:
>
> On Wed, Feb 22, 2017 at 12:47 AM, Melvyn Sopacua <[email protected] 
> <javascript:>> wrote: 
> > On Tuesday 21 February 2017 19:00:42 'Tom Evans' via Django users wrote: 
> > 
> > 
> > 
> >> Previously, these instances were loaded from a JSON fixtures file, 
> > 
> > 
> > 
> > And you can still do that. 
> > 
> > 
> > 
> >> which used to be the recommended way. For our own tests, we simply 
> > 
> >> load these fixtures in the setUp portion of the test; obviously we 
> > 
> >> can't go around modifying tests in third party libraries. 
> > 
> >> I tried taking them out of the fixtures, and adding them instead in a 
> > 
> >> data migration, but this also had the same effect - the instances were 
> > 
> >> there for the first test ran, and then missing for all the subsequent 
> > 
> >> ones. 
> > 
> > 
> > 
> > setUp is run between test methods of a test case. setupTestData is a 
> class 
> > method on the testcase run once per test case. 
> > 
> >> 
> > 
> >> 
> > 
> >> What is the "correct" way of ensuring that these instances exist in 
> > 
> >> the test database before any test is run? 
> > 
> > 
> > 
> > All explained in the docs. 
> > 
> > Either redeclare the same fixtures for different test cases or 
> reorganize 
> > your testcases to share the same fixture(s). 
> > 
>
> I think you have misunderstood: 
>
> 1) The test cases belong to a library and cannot be modified 
> 2) The initial data is populated from a data migration and not from a 
> fixture, as that is not recommended [1] 
>
> Data is placed in to the test database using migrations, but after the 
> first test has been run the data is flushed out again, causing the 
> second test to fail. 
> I would like the all the tests to pass: 
>   * I don't want to put the same data into fixtures as well as migrations 
> (DRY) 
>   * I don't want to modify the 3rd party library. 
>
> How? 
>
> Cheers 
>
> Tom 
>
> [1] 
> https://docs.djangoproject.com/en/1.10/howto/initial-data/#providing-initial-data-with-migrations
>  
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" 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-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7d58066c-79fb-451a-9369-abf86101ccfc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to