Ticket #14087: zip_egg_fixed.3.diff

File zip_egg_fixed.3.diff, 22.3 KB (added by bhuztez, 12 years ago)

if management has already been imported and is not a package

  • django/core/management/__init__.py

    diff --git a/django/core/management/__init__.py b/django/core/management/__init__.py
    index bb03082..78e2a74 100644
    a b import os  
    22import sys
    33from optparse import OptionParser, NO_DEFAULT
    44import imp
     5import pkgutil
    56import warnings
    67
    78from django.core.management.base import BaseCommand, CommandError, handle_default_options
    8 from django.utils.importlib import import_module
     9from django.utils.importlib import import_module, find_package_path
    910
    1011# For backwards compatibility: get_version() used to be in this module.
    1112from django import get_version
    def find_commands(management_dir):  
    2122
    2223    Returns an empty list if no commands are defined.
    2324    """
    24     command_dir = os.path.join(management_dir, 'commands')
    2525    try:
    26         return [f[:-3] for f in os.listdir(command_dir)
    27                 if not f.startswith('_') and f.endswith('.py')]
    28     except OSError:
     26        commands_dir = find_package_path('commands', [management_dir])[0]
     27        return [name for loader,name,ispkg in pkgutil.iter_modules([commands_dir])
     28                if not name.startswith('_') ]
     29    except ImportError:
    2930        return []
    3031
    3132def find_management_module(app_name):
    def find_management_module(app_name):  
    3738    """
    3839    parts = app_name.split('.')
    3940    parts.append('management')
    40     parts.reverse()
    41     part = parts.pop()
    42     path = None
    43 
    44     # When using manage.py, the project module is added to the path,
    45     # loaded, then removed from the path. This means that
    46     # testproject.testapp.models can be loaded in future, even if
    47     # testproject isn't in the path. When looking for the management
    48     # module, we need look for the case where the project name is part
    49     # of the app_name but the project directory itself isn't on the path.
    50     try:
    51         f, path, descr = imp.find_module(part,path)
    52     except ImportError,e:
    53         if os.path.basename(os.getcwd()) != part:
    54             raise e
     41
     42    for i in range(len(parts), 0, -1):
     43        try:
     44            path = sys.modules['.'.join(parts[:i])].__path__
     45        except AttributeError:
     46            raise ImportError("No package named %s" % parts[i-1])
     47        except KeyError:
     48            continue
     49
     50        parts = parts[i:]
     51        parts.reverse()
     52        break
     53    else:
     54        parts.reverse()
     55        part = parts.pop()
     56        path = None
     57
     58        # When using manage.py, the project module is added to the path,
     59        # loaded, then removed from the path. This means that
     60        # testproject.testapp.models can be loaded in future, even if
     61        # testproject isn't in the path. When looking for the management
     62        # module, we need look for the case where the project name is part
     63        # of the app_name but the project directory itself isn't on the path.
     64        try:
     65            path = find_package_path(part, path)
     66        except ImportError,e:
     67            if os.path.basename(os.getcwd()) != part:
     68                raise e
    5569
    5670    while parts:
    5771        part = parts.pop()
    58         f, path, descr = imp.find_module(part, path and [path] or None)
    59     return path
     72        path = find_package_path(part, path)
     73    return path[0]
    6074
    6175def load_command_class(app_name, name):
    6276    """
  • 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 17a2ccb..05c3958 100644
    a b class AdminScriptTestCase(unittest.TestCase):  
    9090    def run_test(self, script, args, settings_file=None, apps=None):
    9191        project_dir = os.path.dirname(test_dir)
    9292        base_dir = os.path.dirname(project_dir)
     93        lib1_dir = os.path.join(os.path.dirname(__file__), 'lib1')
     94        lib2_dir = os.path.join(os.path.dirname(__file__), 'lib2')
     95        lib3_dir = os.path.join(os.path.dirname(__file__), 'lib3')
     96        eggs_dir = os.path.join(os.path.dirname(__file__), 'eggs')
    9397        ext_backend_base_dirs = self._ext_backend_paths()
    9498
    9599        # Remember the old environment
    class AdminScriptTestCase(unittest.TestCase):  
    107111            os.environ['DJANGO_SETTINGS_MODULE'] = settings_file
    108112        elif 'DJANGO_SETTINGS_MODULE' in os.environ:
    109113            del os.environ['DJANGO_SETTINGS_MODULE']
    110         python_path = [project_dir, base_dir]
     114        python_path = [project_dir, base_dir, lib1_dir, lib2_dir, lib3_dir]
    111115        python_path.extend(ext_backend_base_dirs)
    112116        os.environ[python_path_var_name] = os.pathsep.join(python_path)
    113117
    class StartProject(LiveServerTestCase, AdminScriptTestCase):  
    14891493        self.assertNoOutput(err)
    14901494        self.assertTrue(os.path.isdir(testproject_dir))
    14911495        self.assertTrue(os.path.exists(os.path.join(testproject_dir, 'run.py')))
     1496
     1497class NamespacePackagedApps(AdminScriptTestCase):
     1498    def setUp(self):
     1499        self.write_settings('settings.py', apps=['nons_app', 'nsapps.contrib.app1','nsapps.contrib.app2','exapps.app3', 'egg_module'])
     1500        settings_file = open(os.path.join(test_dir, 'settings.py'), 'a')
     1501        settings_file.write('import _addsitedir')
     1502        settings_file.close()
     1503       
     1504    def tearDown(self):
     1505        self.remove_settings('settings.py')
     1506
     1507    def test_help(self):
     1508        out, err = self.run_manage(['help'])
     1509        self.assertNoOutput(err)
     1510        self.assertOutput(out, "nons_app_command1")
     1511        self.assertOutput(out, "app1_command1")
     1512        self.assertOutput(out, "app2_command1")
     1513        self.assertOutput(out, "app3_command1")
     1514        self.assertOutput(out, "egg_command")
     1515
     1516    def test_nons_app(self):
     1517        args = ['nons_app_command1']
     1518        out, err = self.run_manage(args)
     1519        self.assertNoOutput(err)
     1520        self.assertOutput(out, "EXECUTE:nons_app_command1")
     1521
     1522    def test_nsapps(self):
     1523        args = ['app1_command1']
     1524        out, err = self.run_manage(args)
     1525        self.assertNoOutput(err)
     1526        self.assertOutput(out, "EXECUTE:app1_command1")
     1527
     1528        args = ['app2_command1']
     1529        out, err = self.run_manage(args)
     1530        self.assertNoOutput(err)
     1531        self.assertOutput(out, "EXECUTE:app2_command1")
     1532
     1533    def test_exapps(self):
     1534        args = ['app3_command1']
     1535        out, err = self.run_manage(args)
     1536        self.assertNoOutput(err)
     1537        self.assertOutput(out, "EXECUTE:app3_command1")
     1538
     1539    def test_exapps(self):
     1540        args = ['egg_command']
     1541        out, err = self.run_manage(args)
     1542        self.assertNoOutput(err)
     1543        self.assertOutput(out, "EXECUTE:egg_command")
     1544
     1545
     1546class PreloadedNamespacePackagedApps(AdminScriptTestCase):
     1547    def setUp(self):
     1548        self.write_settings('settings.py', apps=['nsapps.contrib.app1','nsapps.contrib.app2'])
     1549        settings_file = open(os.path.join(test_dir, 'settings.py'), 'a')
     1550        settings_file.write('import nsapps')
     1551        settings_file.close()
     1552       
     1553    def tearDown(self):
     1554        self.remove_settings('settings.py')
     1555
     1556    def test_help(self):
     1557        out, err = self.run_manage(['help'])
     1558        self.assertNoOutput(err)
     1559        self.assertOutput(out, "app1_command1")
     1560        self.assertOutput(out, "app2_command1")
     1561
     1562    def test_nsapps(self):
     1563        args = ['app1_command1']
     1564        out, err = self.run_manage(args)
     1565        self.assertNoOutput(err)
     1566        self.assertOutput(out, "EXECUTE:app1_command1")
     1567
     1568        args = ['app2_command1']
     1569        out, err = self.run_manage(args)
     1570        self.assertNoOutput(err)
     1571        self.assertOutput(out, "EXECUTE:app2_command1")
     1572
     1573
     1574class NonPackageManagementApps(AdminScriptTestCase):
     1575    def setUp(self):
     1576        self.write_settings('settings.py', apps=['npapp'])
     1577        settings_file = open(os.path.join(test_dir, 'settings.py'), 'a')
     1578        settings_file.write('import npapp.management')
     1579        settings_file.close()
     1580
     1581    def tearDown(self):
     1582        self.remove_settings('settings.py')
     1583
     1584    def test_help(self):
     1585        out, err = self.run_manage(['help'])
     1586        self.assertNoOutput(err)
     1587       
     1588
Back to Top