PageRenderTime 38ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/patches/NoseDjango-0.6.patch

http://github.com/Fantomas42/django-blog-zinnia
Patch | 40 lines | 39 code | 1 blank | 0 comment | 0 complexity | e429a2b14bc4b8ff7d3dbfc8744fa0ab MD5 | raw file
Possible License(s): BSD-3-Clause, GPL-3.0
  1. --- nosedjango/nosedjango.py
  2. +++ nosedjango/nosedjango.py
  3. @@ -14,7 +14,10 @@ import nose.case
  4. # search the current working directory and all parent directories to find
  5. # the settings file
  6. from nose.importer import add_path
  7. -os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
  8. +
  9. +if 'DJANGO_SETTINGS_MODULE' not in os.environ:
  10. + os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
  11. +
  12. import re
  13. NT_ROOT = re.compile(r"^[a-zA-Z]:\\$")
  14. def get_SETTINGS_PATH():
  15. @@ -58,22 +61,9 @@ class NoseDjango(Plugin):
  16. connection over to that database. Then call install() to install
  17. all apps listed in the loaded settings module.
  18. """
  19. - # Add the working directory (and any package parents) to sys.path
  20. - # before trying to import django modules; otherwise, they won't be
  21. - # able to find project.settings if the working dir is project/ or
  22. - # project/..
  23. -
  24. - if not SETTINGS_PATH:
  25. - sys.stderr.write("Can't find Django settings file!\n")
  26. - # short circuit if no settings file can be found
  27. - return
  28. -
  29. - if self.conf.addPaths:
  30. - map(add_path, self.conf.where)
  31. -
  32. - add_path(SETTINGS_PATH)
  33. - sys.path.append(SETTINGS_PATH)
  34. - import settings
  35. + # use dynamical import: we not necessary use settings.py
  36. + __import__(os.environ['DJANGO_SETTINGS_MODULE'])
  37. + settings = sys.modules[os.environ['DJANGO_SETTINGS_MODULE']]
  38. # Some Django code paths evaluate differently
  39. # between DEBUG and not DEBUG. Example of this include the url