Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 9th, 2012  |  syntax: None  |  size: 1.28 KB  |  hits: 18  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. """
  2. You need the ``BASE_PATH`` and ``TEST_DISCOVERY_ROOT`` settings in order for
  3. this test runner to work.
  4.  
  5. ``BASE_PATH`` should be the directory containing your top-level package(s); in
  6. other words, the directory that should be on ``sys.path`` for your code to
  7. import. This is the directory containing ``manage.py`` in the new Django 1.4
  8. project layout.
  9.  
  10. ``TEST_DISCOVERY_ROOT`` should be the root directory to discover tests
  11. within. You could make this the same as ``BASE_PATH`` if you want tests to be
  12. discovered anywhere in your project. If you want tests to only be discovered
  13. within, say, a top-level ``tests`` directory, you'd set ``TEST_DISCOVERY_ROOT``
  14. as shown below.
  15.  
  16. And you need to point the ``TEST_RUNNER`` setting to the ``DiscoveryRunner``
  17. class above.
  18.  
  19. """
  20. import os.path
  21.  
  22. # This is correct for the Django 1.4-style project layout; for the old-style
  23. # project layout with ``settings.py`` and ``manage.py`` in the same directory,
  24. # you'd want to only call ``os.path.dirname`` once.
  25. BASE_PATH = os.path.dirname(os.path.dirname(__file__))
  26.  
  27. # This would be if you put all your tests within a top-level "tests" package.
  28. TEST_DISCOVERY_ROOT = os.path.join(BASE_PATH, "tests")
  29.  
  30. # This assumes you place the above ``DiscoveryRunner`` in ``tests/runner.py``.
  31. TEST_RUNNER = "tests.runner.DiscoveryRunner"