Giter Club home page Giter Club logo

Comments (5)

greatestape avatar greatestape commented on May 27, 2024

Django provides a utility decorator called override_settings for cases like this. I haven't used it, but I'd suggest giving it a try:

https://docs.djangoproject.com/en/dev/topics/testing/#django.test.utils.override_settings

Also, you need a way to test that the fix actually works. We had a hard time with the issue in our environment because it was only happening to some of us, so nailing down good way to test might be tricky.

from django-guardian.

funkaoshi avatar funkaoshi commented on May 27, 2024

To verify the fix you could create a dummy test case class that would simply assert that Grappelli wasn't in the installed apps. And you could run the Grapelli tests and this new test case from the command line. I think when you list things explicity on the command line they are run in sequence.

I should just fix this and submit a pull request.

from django-guardian.

funkaoshi avatar funkaoshi commented on May 27, 2024

So if you print out the contents of the INSTALLED_APPS after the tearDown method 'restores' them you'll see that nothing has changed. After those tests are run there are 3 copies of 'grapelli' in the installed apps. (One for each test case in that class.) Example:

=========================================================
Creating test database for alias 'default'...
........................................................................................................................................................................................Before - ['grappelli', 'django.contrib.auth', 'django.contrib.sessions', 'django.contrib.contenttypes', 'django.contrib.admin', 'django.contrib.sites', 'guardian']
After - ['grappelli', 'django.contrib.auth', 'django.contrib.sessions', 'django.contrib.contenttypes', 'django.contrib.admin', 'django.contrib.sites', 'guardian']
. Before - ['grappelli', 'grappelli', 'django.contrib.auth', 'django.contrib.sessions', 'django.contrib.contenttypes', 'django.contrib.admin', 'django.contrib.sites', 'guardian']
After - ['grappelli', 'grappelli', 'django.contrib.auth', 'django.contrib.sessions', 'django.contrib.contenttypes', 'django.contrib.admin', 'django.contrib.sites', 'guardian']
.Before - ['grappelli', 'grappelli', 'grappelli', 'django.contrib.auth', 'django.contrib.sessions', 'django.contrib.contenttypes', 'django.contrib.admin', 'django.contrib.sites', 'guardian']
After - ['grappelli', 'grappelli', 'grappelli', 'django.contrib.auth', 'django.contrib.sessions', 'django.contrib.contenttypes', 'django.contrib.admin', 'django.contrib.sites', 'guardian']
....................................................................
----------------------------------------------------------------------
Ran 254 tests in 9.926s

If we simply restore the original installed apps everything works out.

=========================================================
Creating test database for alias 'default'...
........................................................................................................................................................................................Before - ['grappelli', 'django.contrib.auth', 'django.contrib.sessions', 'django.contrib.contenttypes', 'django.contrib.admin', 'django.contrib.sites', 'guardian']
After - ['django.contrib.auth', 'django.contrib.sessions', 'django.contrib.contenttypes', 'django.contrib.admin', 'django.contrib.sites', 'guardian']
.Before - ['grappelli', 'django.contrib.auth', 'django.contrib.sessions', 'django.contrib.contenttypes', 'django.contrib.admin', 'django.contrib.sites', 'guardian']
After - ['django.contrib.auth', 'django.contrib.sessions', 'django.contrib.contenttypes', 'django.contrib.admin', 'django.contrib.sites', 'guardian']
.Before - ['grappelli', 'django.contrib.auth', 'django.contrib.sessions', 'django.contrib.contenttypes', 'django.contrib.admin', 'django.contrib.sites', 'guardian']
After - ['django.contrib.auth', 'django.contrib.sessions', 'django.contrib.contenttypes', 'django.contrib.admin', 'django.contrib.sites', 'guardian']
....................................................................
----------------------------------------------------------------------
Ran 254 tests in 9.808s

It looks like that override_settings decorater is coming to a version of Django near you soon. (It's not part of 1.3.1 anyway.)

from django-guardian.

funkaoshi avatar funkaoshi commented on May 27, 2024

See this pull request: #58

from django-guardian.

funkaoshi avatar funkaoshi commented on May 27, 2024

My pull request was merged.

from django-guardian.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.