Giter Site home page Giter Site logo

Django compatibility about green HOT 9 CLOSED

cleancut avatar cleancut commented on July 26, 2024
Django compatibility

from green.

Comments (9)

CleanCut avatar CleanCut commented on July 26, 2024 1

@pkrefta No problem. You can set the verbosity by adding a Green config file (see the bottom of the help; the section starts with CONFIG FILES.

from green.

CleanCut avatar CleanCut commented on July 26, 2024

Ah, my first run-in with Django. Until now, it has only been a word I have seen tossed around in distant forums and conference talks. :-) Thanks for providing the minimal project and example command to start with, that helps a bunch.

This looks like a good place for research to start

I'll check this out and see how hard this looks to do after I finish issues #14 and #7 that I'm deep into.

If anyone wants to check it out further in the meantime, please do!

from green.

CleanCut avatar CleanCut commented on July 26, 2024

Ok, I got curious so I went and looked at things. It looks like the apparently standard Django manage.py script just hooks into a command-line processing library inside of Django (decent design, there).

The ./manage.py test subcommand has a --testrunner=TESTRUNNER option that expects some type of testrunner class. Apparently there are Django-specific expectations for the test runner, as neither green.runner.GreenTestRunner nor unittest.runner.TextTestRunner will work when passed in. I bet this is going to be the best integration point with Django.

I need to find Django's expectations (hopefully nicely documented) for the test runner class they want to use. Assuming the expectations are not too crazy, I could write a green.runner.Django class that conforms to those expectations.

It may be wise for me to implement #20 before implementing this functionality, otherwise there would be no way to configure green when you're running it through Django.

I envision an implementation where the user would end up doing this to run their Django tests through Green:

./manage.py test --testrunner=green.runner.Django

So I think I know where to go for this one, but I want to resolve some of these other issues before I hit this one. (Pull requests welcome in the meantime!)

If there is some other (better) integration point with Django, someone please speak up and let me know!

from green.

CleanCut avatar CleanCut commented on July 26, 2024

#20 has been implemented. No more blockers that I know of.

from green.

CleanCut avatar CleanCut commented on July 26, 2024

Okay, I have been working on this all morning and I'm afraid I am a bit stumped.

Django won't let you import the test stuff without already being configured in the context of a project. That makes it really, really annoying to develop and test something you want to subclass.

>>> from django.test.runner import DiscoverRunner
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Python/2.7/site-packages/django/test/__init__.py", line 5, in <module>
    from django.test.client import Client, RequestFactory
  File "/Library/Python/2.7/site-packages/django/test/client.py", line 11, in <module>
    from django.contrib.auth import authenticate, login, logout, get_user_model
  File "/Library/Python/2.7/site-packages/django/contrib/auth/__init__.py", line 6, in <module>
    from django.middleware.csrf import rotate_token
  File "/Library/Python/2.7/site-packages/django/middleware/csrf.py", line 14, in <module>
    from django.utils.cache import patch_vary_headers
  File "/Library/Python/2.7/site-packages/django/utils/cache.py", line 26, in <module>
    from django.core.cache import get_cache
  File "/Library/Python/2.7/site-packages/django/core/cache/__init__.py", line 69, in <module>
    if DEFAULT_CACHE_ALIAS not in settings.CACHES:
  File "/Library/Python/2.7/site-packages/django/conf/__init__.py", line 54, in __getattr__
    self._setup(name)
  File "/Library/Python/2.7/site-packages/django/conf/__init__.py", line 47, in _setup
    % (desc, ENVIRONMENT_VARIABLE))
django.core.exceptions.ImproperlyConfigured: Requested setting CACHES, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.

from green.

CleanCut avatar CleanCut commented on July 26, 2024

Not stumped anymore! If the django settings env variable is not present, I use stubbed out config settings. I've got a prototype working already. :)

from green.

CleanCut avatar CleanCut commented on July 26, 2024

Django integration documentation is here, at the moment: https://github.com/CleanCut/green#integration

from green.

CleanCut avatar CleanCut commented on July 26, 2024

More specifically, here's a link to the sub-section directly: https://github.com/CleanCut/green#django

from green.

pkrefta avatar pkrefta commented on July 26, 2024

@CleanCut Thanks for django. I don't want to open another to ask simple question - how can I set verbosity for DjangoRunner ? 😄

from green.

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.