#!/usr/bin/env python
"""
Custom ``nosetests`` runner that make possible to run ``nosetests`` for your
Django projects without installed ``setuptools``.
"""

import nose
from nose.plugins.manager import EntryPointPluginManager

from tddspry.noseplugins import DjangoPlugin


if __name__ == '__main__':
    found, kwargs = False, {}

    manager = EntryPointPluginManager()
    manager.loadPlugins()

    for plugin in manager.plugins:
        if isinstance(plugin, DjangoPlugin):
            found = True
            break

    if not found:
        kwargs = {'addplugins': [DjangoPlugin()]}

    nose.main(**kwargs)

@@ -151,16 +151,27 @@
 %60.%0A%22%22%22%0A%0A
+import os%0A%0A
 import n
@@ -174,16 +174,16 @@
 rt nose%0A
-
 from nos
@@ -306,16 +306,84 @@
 ain__':%0A
+    # Try to find that DjangoPlugin loaded from entry_points or not%0A
     foun
@@ -596,16 +596,42 @@
  break%0A%0A
+    # If not manually add%0A
     if n
@@ -691,16 +691,108 @@
 in()%5D%7D%0A%0A
+    # Enable DjangoPlugin%0A    os.environ%5B'NOSE_WITH_DJANGO'%5D = '1'%0A%0A    # Run %60%60nosetests%60%60%0A
     nose

Enable ``DjangoPlugin`` by default if tests running by ``django-nosetests.py`` script.