Ticket #596: pep-302.diff

File pep-302.diff, 22.3 KB (added by bhuztez, 13 years ago)

zip_egg_fixed.5.diff from #14087

  • django/core/management/__init__.py

    diff --git a/django/core/management/__init__.py b/django/core/management/__init__.py
    index 8e83304..74bb558 100644
    a b import os  
    33import sys
    44from optparse import OptionParser, NO_DEFAULT
    55import imp
     6import pkgutil
    67import warnings
    78
    89from django.core.management.base import BaseCommand, CommandError, handle_default_options
    910from django.core.management.color import color_style
    10 from django.utils.importlib import import_module
     11from django.utils.importlib import import_module, find_package_path
    1112
    1213# For backwards compatibility: get_version() used to be in this module.
    1314from django import get_version
    def find_commands(management_dir):  
    2324
    2425    Returns an empty list if no commands are defined.
    2526    """
    26     command_dir = os.path.join(management_dir, 'commands')
    2727    try:
    28         return [f[:-3] for f in os.listdir(command_dir)
    29                 if not f.startswith('_') and f.endswith('.py')]
    30     except OSError:
     28        commands_dir = find_package_path('commands', [management_dir])[0]
     29        return [name for loader,name,ispkg in pkgutil.iter_modules([commands_dir])
     30                if not name.startswith('_') ]
     31    except ImportError:
    3132        return []
    3233
    3334def find_management_module(app_name):
    def find_management_module(app_name):  
    3940    """
    4041    parts = app_name.split('.')
    4142    parts.append('management')
    42     parts.reverse()
    43     part = parts.pop()
    44     path = None
    45 
    46     # When using manage.py, the project module is added to the path,
    47     # loaded, then removed from the path. This means that
    48     # testproject.testapp.models can be loaded in future, even if
    49     # testproject isn't in the path. When looking for the management
    50     # module, we need look for the case where the project name is part
    51     # of the app_name but the project directory itself isn't on the path.
    52     try:
    53         f, path, descr = imp.find_module(part,path)
    54     except ImportError,e:
    55         if os.path.basename(os.getcwd()) != part:
    56             raise e
     43
     44    for i in range(len(parts), 0, -1):
     45        try:
     46            path = sys.modules['.'.join(parts[:i])].__path__
     47        except AttributeError:
     48            raise ImportError("No package named %s" % parts[i-1])
     49        except KeyError:
     50            continue
     51
     52        parts = parts[i:]
     53        parts.reverse()
     54        break
     55    else:
     56        parts.reverse()
     57        part = parts.pop()
     58        path = None
     59
     60        # When using manage.py, the project module is added to the path,
     61        # loaded, then removed from the path. This means that
     62        # testproject.testapp.models can be loaded in future, even if
     63        # testproject isn't in the path. When looking for the management
     64        # module, we need look for the case where the project name is part
     65        # of the app_name but the project directory itself isn't on the path.
     66        try:
     67            path = find_package_path(part, path)
     68        except ImportError,e:
     69            if os.path.basename(os.getcwd()) != part:
     70                raise e
    5771
    5872    while parts:
    5973        part = parts.pop()
    60         f, path, descr = imp.find_module(part, path and [path] or None)
    61     return path
     74        path = find_package_path(part, path)
     75    return path[0]
    6276
    6377def load_command_class(app_name, name):
    6478    """
  • django/utils/importlib.py

    diff --git a/django/utils/importlib.py b/django/utils/importlib.py
    index ef4d0e4..f53abd9 100644
    a b  
    11# Taken from Python 2.7 with permission from/by the original author.
     2import os
    23import sys
     4import imp
     5import pkgutil
     6import warnings
    37
    48def _resolve_name(name, package, level):
    59    """Return the absolute name of the module to be imported."""
    def import_module(name, package=None):  
    3438        name = _resolve_name(name[level:], package, level)
    3539    __import__(name)
    3640    return sys.modules[name]
     41
     42
     43def find_package_path(name, path=None):
     44    """Finds search path for package with given name.
     45
     46    The 'path' argument defaults to ``sys.path``.
     47
     48    Raises ImportError if no search path could be found.
     49    """
     50    if path is None:
     51        path = sys.path
     52
     53    results = []
     54
     55    for path_item in path:
     56        importer = get_importer(path_item)
     57
     58        if importer is None:
     59            continue
     60
     61        try:
     62            loader = importer.find_module(name)
     63
     64            if loader is not None:
     65
     66                if not hasattr(loader, 'is_package'):
     67                    warnings.warn(
     68                        "Django cannot find search path for package '%s' ",
     69                        "under '%s', because the loader returned by '%s' does ",
     70                        "not implement 'is_package' method."%(
     71                            name,
     72                            path_item,
     73                            importer.__class__.__name__))
     74                    continue
     75
     76                if not hasattr(loader, 'get_filename'):
     77                    warnings.warn(
     78                        "Django cannot find search path for package '%s' ",
     79                        "under '%s', because the loader returned by '%s' does ",
     80                        "not implement 'get_filename' method."%(
     81                            name,
     82                            path_item,
     83                            importer.__class__.__name__))
     84                    continue
     85
     86                if loader.is_package(name):
     87                    results.append(os.path.dirname(loader.get_filename(name)))
     88        except ImportError:
     89            pass
     90
     91    if not results:
     92        raise ImportError("No package named %s" % name)
     93
     94    return results
     95
     96
     97get_importer = pkgutil.get_importer
     98
     99try:
     100    import zipimport
     101
     102    if hasattr(zipimport.zipimporter, 'get_filename'):
     103        class ZipImporter(zipimport.zipimporter):
     104            def get_filename(self, fullname):
     105                archivepath = os.path.join(self.archive, self.prefix)
     106                if self.is_package(fullname):
     107                    return os.path.join(archivepath, fullname, '__init__.py')
     108
     109                return os.path.join(archivepath, fullname + '.py')
     110
     111        def get_importer(path_item):
     112            importer = pkgutil.get_importer(path_item)
     113
     114            if isinstance(importer, zipimport.zipimporter):
     115                archivepath = os.path.join(importer.archive, importer.prefix)
     116                importer = ZipImporter(os.path.dirname(archivepath))
     117
     118            return importer
     119
     120except ImportError:
     121    pass
     122
     123
  • new file tests/regressiontests/admin_scripts/lib1/nons_app/management/commands/nons_app_command1.py

    diff --git a/tests/regressiontests/admin_scripts/lib1/nons_app/__init__.py b/tests/regressiontests/admin_scripts/lib1/nons_app/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/tests/regressiontests/admin_scripts/lib1/nons_app/management/__init__.py b/tests/regressiontests/admin_scripts/lib1/nons_app/management/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/tests/regressiontests/admin_scripts/lib1/nons_app/management/commands/__init__.py b/tests/regressiontests/admin_scripts/lib1/nons_app/management/commands/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/tests/regressiontests/admin_scripts/lib1/nons_app/management/commands/nons_app_command1.py b/tests/regressiontests/admin_scripts/lib1/nons_app/management/commands/nons_app_command1.py
    new file mode 100644
    index 0000000..a393663
    - +  
     1from django.core.management.base import BaseCommand
     2
     3class Command(BaseCommand):
     4    help = 'Test managment commands in non-namespaced app'
     5    requires_model_validation = False
     6    args = ''
     7
     8    def handle(self, *labels, **options):
     9        print 'EXECUTE:nons_app_command1'
  • new file tests/regressiontests/admin_scripts/lib1/nsapps/__init__.py

    diff --git a/tests/regressiontests/admin_scripts/lib1/nons_app/models.py b/tests/regressiontests/admin_scripts/lib1/nons_app/models.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/tests/regressiontests/admin_scripts/lib1/npapp/__init__.py b/tests/regressiontests/admin_scripts/lib1/npapp/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/tests/regressiontests/admin_scripts/lib1/npapp/management.py b/tests/regressiontests/admin_scripts/lib1/npapp/management.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/tests/regressiontests/admin_scripts/lib1/npapp/models.py b/tests/regressiontests/admin_scripts/lib1/npapp/models.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/tests/regressiontests/admin_scripts/lib1/nsapps/__init__.py b/tests/regressiontests/admin_scripts/lib1/nsapps/__init__.py
    new file mode 100644
    index 0000000..32f26d8
    - +  
     1# http://packages.python.org/distribute/setuptools.html#namespace-packages
     2try:
     3    __import__('pkg_resources').declare_namespace(__name__)
     4except ImportError:
     5    from pkgutil import extend_path
     6    __path__ = extend_path(__path__, __name__)
  • new file tests/regressiontests/admin_scripts/lib1/nsapps/contrib/__init__.py

    diff --git a/tests/regressiontests/admin_scripts/lib1/nsapps/contrib/__init__.py b/tests/regressiontests/admin_scripts/lib1/nsapps/contrib/__init__.py
    new file mode 100644
    index 0000000..32f26d8
    - +  
     1# http://packages.python.org/distribute/setuptools.html#namespace-packages
     2try:
     3    __import__('pkg_resources').declare_namespace(__name__)
     4except ImportError:
     5    from pkgutil import extend_path
     6    __path__ = extend_path(__path__, __name__)
  • new file tests/regressiontests/admin_scripts/lib1/nsapps/contrib/app1/management/commands/app1_command1.py

    diff --git a/tests/regressiontests/admin_scripts/lib1/nsapps/contrib/app1/__init__.py b/tests/regressiontests/admin_scripts/lib1/nsapps/contrib/app1/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/tests/regressiontests/admin_scripts/lib1/nsapps/contrib/app1/management/__init__.py b/tests/regressiontests/admin_scripts/lib1/nsapps/contrib/app1/management/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/tests/regressiontests/admin_scripts/lib1/nsapps/contrib/app1/management/commands/__init__.py b/tests/regressiontests/admin_scripts/lib1/nsapps/contrib/app1/management/commands/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/tests/regressiontests/admin_scripts/lib1/nsapps/contrib/app1/management/commands/app1_command1.py b/tests/regressiontests/admin_scripts/lib1/nsapps/contrib/app1/management/commands/app1_command1.py
    new file mode 100644
    index 0000000..2f479bb
    - +  
     1from django.core.management.base import BaseCommand
     2
     3class Command(BaseCommand):
     4    help = 'Test managment commands in namespaced apps'
     5    requires_model_validation = False
     6    args = ''
     7
     8    def handle(self, *labels, **options):
     9        print 'EXECUTE:app1_command1'
  • new file tests/regressiontests/admin_scripts/lib2/nsapps/__init__.py

    diff --git a/tests/regressiontests/admin_scripts/lib1/nsapps/contrib/app1/models.py b/tests/regressiontests/admin_scripts/lib1/nsapps/contrib/app1/models.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/tests/regressiontests/admin_scripts/lib2/nsapps/__init__.py b/tests/regressiontests/admin_scripts/lib2/nsapps/__init__.py
    new file mode 100644
    index 0000000..32f26d8
    - +  
     1# http://packages.python.org/distribute/setuptools.html#namespace-packages
     2try:
     3    __import__('pkg_resources').declare_namespace(__name__)
     4except ImportError:
     5    from pkgutil import extend_path
     6    __path__ = extend_path(__path__, __name__)
  • new file tests/regressiontests/admin_scripts/lib2/nsapps/contrib/__init__.py

    diff --git a/tests/regressiontests/admin_scripts/lib2/nsapps/contrib/__init__.py b/tests/regressiontests/admin_scripts/lib2/nsapps/contrib/__init__.py
    new file mode 100644
    index 0000000..32f26d8
    - +  
     1# http://packages.python.org/distribute/setuptools.html#namespace-packages
     2try:
     3    __import__('pkg_resources').declare_namespace(__name__)
     4except ImportError:
     5    from pkgutil import extend_path
     6    __path__ = extend_path(__path__, __name__)
  • new file tests/regressiontests/admin_scripts/lib2/nsapps/contrib/app2/management/commands/app2_command1.py

    diff --git a/tests/regressiontests/admin_scripts/lib2/nsapps/contrib/app2/__init__.py b/tests/regressiontests/admin_scripts/lib2/nsapps/contrib/app2/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/tests/regressiontests/admin_scripts/lib2/nsapps/contrib/app2/management/__init__.py b/tests/regressiontests/admin_scripts/lib2/nsapps/contrib/app2/management/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/tests/regressiontests/admin_scripts/lib2/nsapps/contrib/app2/management/commands/__init__.py b/tests/regressiontests/admin_scripts/lib2/nsapps/contrib/app2/management/commands/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/tests/regressiontests/admin_scripts/lib2/nsapps/contrib/app2/management/commands/app2_command1.py b/tests/regressiontests/admin_scripts/lib2/nsapps/contrib/app2/management/commands/app2_command1.py
    new file mode 100644
    index 0000000..b9e20a7
    - +  
     1from django.core.management.base import BaseCommand
     2
     3class Command(BaseCommand):
     4    help = 'Test managment commands in namespaced apps'
     5    requires_model_validation = False
     6    args = ''
     7
     8    def handle(self, *labels, **options):
     9        print 'EXECUTE:app2_command1'
  • new file tests/regressiontests/admin_scripts/lib3/_addsitedir.py

    diff --git a/tests/regressiontests/admin_scripts/lib2/nsapps/contrib/app2/models.py b/tests/regressiontests/admin_scripts/lib2/nsapps/contrib/app2/models.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/tests/regressiontests/admin_scripts/lib3/_addsitedir.py b/tests/regressiontests/admin_scripts/lib3/_addsitedir.py
    new file mode 100644
    index 0000000..9e264d2
    - +  
     1import os.path, site; site.addsitedir(os.path.dirname(__file__))
  • new file tests/regressiontests/admin_scripts/lib3/egg_module.pth

    diff --git a/tests/regressiontests/admin_scripts/lib3/egg_module.pth b/tests/regressiontests/admin_scripts/lib3/egg_module.pth
    new file mode 100644
    index 0000000..9367ab5
    - +  
     1test_egg.egg
  • new file tests/regressiontests/admin_scripts/lib3/exapps-nspkg.pth

    diff --git a/tests/regressiontests/admin_scripts/lib3/exapps-nspkg.pth b/tests/regressiontests/admin_scripts/lib3/exapps-nspkg.pth
    new file mode 100644
    index 0000000..1f31155
    - +  
     1import sys,new,os; p = os.path.join(sys._getframe(1).f_locals['sitedir'], *('exapps',)); ie = os.path.exists(os.path.join(p,'__init__.py')); m = not ie and sys.modules.setdefault('exapps',new.module('exapps')); mp = (m or []) and m.__dict__.setdefault('__path__',[]); (p not in mp) and mp.append(p)
  • new file tests/regressiontests/admin_scripts/lib3/exapps/app3/management/commands/app3_command1.py

    diff --git a/tests/regressiontests/admin_scripts/lib3/exapps/app3/__init__.py b/tests/regressiontests/admin_scripts/lib3/exapps/app3/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/tests/regressiontests/admin_scripts/lib3/exapps/app3/management/__init__.py b/tests/regressiontests/admin_scripts/lib3/exapps/app3/management/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/tests/regressiontests/admin_scripts/lib3/exapps/app3/management/commands/__init__.py b/tests/regressiontests/admin_scripts/lib3/exapps/app3/management/commands/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/tests/regressiontests/admin_scripts/lib3/exapps/app3/management/commands/app3_command1.py b/tests/regressiontests/admin_scripts/lib3/exapps/app3/management/commands/app3_command1.py
    new file mode 100644
    index 0000000..97f5d33
    - +  
     1from django.core.management.base import BaseCommand
     2
     3class Command(BaseCommand):
     4    help = 'Test managment commands in namespaced apps'
     5    requires_model_validation = False
     6    args = ''
     7
     8    def handle(self, *labels, **options):
     9        print 'EXECUTE:app3_command1'
  • new file tests/regressiontests/admin_scripts/lib3/exapps/app3/models.py

    diff --git a/tests/regressiontests/admin_scripts/lib3/exapps/app3/models.py b/tests/regressiontests/admin_scripts/lib3/exapps/app3/models.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/tests/regressiontests/admin_scripts/lib3/test_egg.egg b/tests/regressiontests/admin_scripts/lib3/test_egg.egg
    new file mode 100644
    index 0000000000000000000000000000000000000000..d9e57de006a3d602515293f8e980bf3a16fb42c0
    GIT binary patch
    literal 2210
    zcmWIWW@Zs#W&na+g#z{<8U{Fl3|Dt|T~9wZfBgWcG7g3{KxHDAuKle5O78$-K~!ZB
    z^|5C+avd@dV0&QeKT+IcWwzNt$AHBOuWGiW^E|0~S|nLhZ9Ow6Z`b?h&-X7l#KHBh
    zGf2q)-n(7*SQNg9C6^pYKAZ6`^S*BSyQv&cUcXhIbLgw+nTectc?6~3uC9yNw%@sF
    z%ItZU8-gRR@<p(DZr01@&6oUg*2%XH)tT;p3*R&VooCL-z#xL`%wYe}AZOQLy^@NO
    zseK1QE_HeT&--$}fT-Y_2pj#SlFkL2Ia9R1z3&YW$hEDwHMjD;fuxnn<YS_977M&R
    zu%dHMh3c<Wrx~B0zcgk0r=s4kFE_0Ic06}8$L(iDarse;`D34maV9DL^?37iT78$4
    zu;IH0CoB42FDd2_n0t1<bS;nS%|HFW4h3s`69&1M3mpESfSt^C-3aJd1`w7-c5zB-
    zL26z~YF=_>d`@Owb}`85T&Q|ip0Nz)2I>J}F=V|Z`33Pgsb#4-AWf<1>G8SwDWy57
    zXxfpjMv2p^%mUrw#59O{NK!eBmQ+AiA`Av67Koo#6`-amkh_o+#>Z#oWtPOp>lIYO
    zVvd0U-EcHLxrup+>8ZJ?c_m2p+{#0>M-kN?Bt1k~DUVZoa(*t*u#{pvc54yVjKvWg
    z3_F2gHQm(j`*xsy9$*5{C2S5TD4{L_2BB}CcONJzf46gee`Y}-UxUeP$C<(gLc3RV
    zY9Cwi_n@qWz2AwZxYCuY=4Gw2oV2^}(@yDPS8>aY?k=--b8BlHne^Ic|6BWKH)7Jy
    zXsq#?eWx}ep56KFx(QD9DgGB`hCMj6_@itPSErDB#zVor9U@z^*FXBlA!>Exjl$u{
    zsuuH{{dm6}Ulb7>vsbSqJM5*w#jS~~)~!DGw}|g^*kb!TX4*Er&D*q1x2SHj|9<>`
    zaDBt~!)B*vi6f<AwA2F1vq-50m~2yXiot1xkx7IZcc}%`1_S~P2OL2(QW*x*hP@O6
    zDP~|$XxP%I4y2K^LCUlMZ&dB*r3+X$So=9-?MP(}#01>A9brNPF#h2Vz?S#XjY7}-
    z2&48O8--F7pqqhS0wB!zjcf+2JV1m8W}XEV2oL~@1#Kpjcto}rTLA&l2#SXgRE;Rv
    z1{N8ZmV*im2mo2$focX)QGo0YYy}9!43Ina;536sCxHqS2mm?hH%{Y_iWiXoAV~$?
    zZJ+`M0zhuF09GEznFLWh!VSafNbCg;!rTVJ=Asrq$icY=OHM`@-Nb_GWJJDZWdo_=
    P1Hv0X>$d>aF)#oC`tnrE
  • tests/regressiontests/admin_scripts/tests.py

    literal 0
    HcmV?d00001
    
    diff --git a/tests/regressiontests/admin_scripts/tests.py b/tests/regressiontests/admin_scripts/tests.py
    index 669c6e8..6408b97 100644
    a b class AdminScriptTestCase(unittest.TestCase):  
    9191    def run_test(self, script, args, settings_file=None, apps=None):
    9292        project_dir = os.path.dirname(test_dir)
    9393        base_dir = os.path.dirname(project_dir)
     94        lib1_dir = os.path.join(os.path.dirname(__file__), 'lib1')
     95        lib2_dir = os.path.join(os.path.dirname(__file__), 'lib2')
     96        lib3_dir = os.path.join(os.path.dirname(__file__), 'lib3')
     97        eggs_dir = os.path.join(os.path.dirname(__file__), 'eggs')
    9498        ext_backend_base_dirs = self._ext_backend_paths()
    9599
    96100        # Remember the old environment
    class AdminScriptTestCase(unittest.TestCase):  
    108112            os.environ['DJANGO_SETTINGS_MODULE'] = settings_file
    109113        elif 'DJANGO_SETTINGS_MODULE' in os.environ:
    110114            del os.environ['DJANGO_SETTINGS_MODULE']
    111         python_path = [project_dir, base_dir]
     115        python_path = [project_dir, base_dir, lib1_dir, lib2_dir, lib3_dir]
    112116        python_path.extend(ext_backend_base_dirs)
    113117        os.environ[python_path_var_name] = os.pathsep.join(python_path)
    114118
    class StartProject(LiveServerTestCase, AdminScriptTestCase):  
    15631567        self.assertOutput(err, "Destination directory '%s' does not exist, please create it first." % testproject_dir)
    15641568        self.assertFalse(os.path.exists(testproject_dir))
    15651569
     1570
     1571class NamespacePackagedApps(AdminScriptTestCase):
     1572    def setUp(self):
     1573        self.write_settings('settings.py', apps=['nons_app', 'nsapps.contrib.app1','nsapps.contrib.app2','exapps.app3', 'egg_module'])
     1574        settings_file = open(os.path.join(test_dir, 'settings.py'), 'a')
     1575        settings_file.write('import _addsitedir')
     1576        settings_file.close()
     1577       
     1578    def tearDown(self):
     1579        self.remove_settings('settings.py')
     1580
     1581    def test_help(self):
     1582        out, err = self.run_manage(['help'])
     1583        self.assertNoOutput(err)
     1584        self.assertOutput(out, "nons_app_command1")
     1585        self.assertOutput(out, "app1_command1")
     1586        self.assertOutput(out, "app2_command1")
     1587        self.assertOutput(out, "app3_command1")
     1588        self.assertOutput(out, "egg_command")
     1589
     1590    def test_nons_app(self):
     1591        args = ['nons_app_command1']
     1592        out, err = self.run_manage(args)
     1593        self.assertNoOutput(err)
     1594        self.assertOutput(out, "EXECUTE:nons_app_command1")
     1595
     1596    def test_nsapps(self):
     1597        args = ['app1_command1']
     1598        out, err = self.run_manage(args)
     1599        self.assertNoOutput(err)
     1600        self.assertOutput(out, "EXECUTE:app1_command1")
     1601
     1602        args = ['app2_command1']
     1603        out, err = self.run_manage(args)
     1604        self.assertNoOutput(err)
     1605        self.assertOutput(out, "EXECUTE:app2_command1")
     1606
     1607    def test_exapps(self):
     1608        args = ['app3_command1']
     1609        out, err = self.run_manage(args)
     1610        self.assertNoOutput(err)
     1611        self.assertOutput(out, "EXECUTE:app3_command1")
     1612
     1613    def test_exapps(self):
     1614        args = ['egg_command']
     1615        out, err = self.run_manage(args)
     1616        self.assertNoOutput(err)
     1617        self.assertOutput(out, "EXECUTE:egg_command")
     1618
     1619
     1620class PreloadedNamespacePackagedApps(AdminScriptTestCase):
     1621    def setUp(self):
     1622        self.write_settings('settings.py', apps=['nsapps.contrib.app1','nsapps.contrib.app2'])
     1623        settings_file = open(os.path.join(test_dir, 'settings.py'), 'a')
     1624        settings_file.write('import nsapps')
     1625        settings_file.close()
     1626       
     1627    def tearDown(self):
     1628        self.remove_settings('settings.py')
     1629
     1630    def test_help(self):
     1631        out, err = self.run_manage(['help'])
     1632        self.assertNoOutput(err)
     1633        self.assertOutput(out, "app1_command1")
     1634        self.assertOutput(out, "app2_command1")
     1635
     1636    def test_nsapps(self):
     1637        args = ['app1_command1']
     1638        out, err = self.run_manage(args)
     1639        self.assertNoOutput(err)
     1640        self.assertOutput(out, "EXECUTE:app1_command1")
     1641
     1642        args = ['app2_command1']
     1643        out, err = self.run_manage(args)
     1644        self.assertNoOutput(err)
     1645        self.assertOutput(out, "EXECUTE:app2_command1")
     1646
     1647
     1648class NonPackageManagementApps(AdminScriptTestCase):
     1649    def setUp(self):
     1650        self.write_settings('settings.py', apps=['npapp'])
     1651        settings_file = open(os.path.join(test_dir, 'settings.py'), 'a')
     1652        settings_file.write('import npapp.management')
     1653        settings_file.close()
     1654
     1655    def tearDown(self):
     1656        self.remove_settings('settings.py')
     1657
     1658    def test_help(self):
     1659        out, err = self.run_manage(['help'])
     1660        self.assertNoOutput(err)
     1661
Back to Top