Ticket #14087: zip_egg_fixed.diff

File zip_egg_fixed.diff, 22.7 KB (added by bhuztez, 13 years ago)

fixed for zip-archived eggs

  • django/core/management/__init__.py

    diff --git a/django/core/management/__init__.py b/django/core/management/__init__.py
    index bb03082..bb5d148 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_importers, find_package_importers
    910
    1011# For backwards compatibility: get_version() used to be in this module.
    1112from django import get_version
    from django import get_version  
    1415# doesn't have to reload every time it's called.
    1516_commands = None
    1617
    17 def find_commands(management_dir):
     18def find_commands(commands_importers):
    1819    """
    1920    Given a path to a management directory, returns a list of all the command
    2021    names that are available.
    2122
    2223    Returns an empty list if no commands are defined.
    2324    """
    24     command_dir = os.path.join(management_dir, 'commands')
    25     try:
    26         return [f[:-3] for f in os.listdir(command_dir)
    27                 if not f.startswith('_') and f.endswith('.py')]
    28     except OSError:
    29         return []
     25    for importer in commands_importers:
     26        for name, ispkg in pkgutil.iter_importer_modules(importer):
     27            if not name.startswith('_'):
     28                yield name
     29
    3030
    31 def find_management_module(app_name):
     31def find_commands_importers(app_name):
    3232    """
    3333    Determines the path to the management module for the given app_name,
    3434    without actually importing the application or the management module.
    def find_management_module(app_name):  
    3636    Raises ImportError if the management module cannot be found for any reason.
    3737    """
    3838    parts = app_name.split('.')
    39     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
     39
     40    for i in range(len(parts), 0, -1):
     41        try:
     42            path = sys.modules['.'.join(parts[:i])].__path__
     43        except KeyError:
     44            continue
     45
     46        parts = parts[i:] + ['management', 'commands']
     47        parts.reverse()
     48        importers = find_importers(path)
     49        break
     50    else:
     51        parts += ['management', 'commands']
     52        parts.reverse()
     53        part = parts.pop()
     54        importers = find_importers()
     55
     56        # When using manage.py, the project module is added to the path,
     57        # loaded, then removed from the path. This means that
     58        # testproject.testapp.models can be loaded in future, even if
     59        # testproject isn't in the path. When looking for the management
     60        # module, we need look for the case where the project name is part
     61        # of the app_name but the project directory itself isn't on the path.
     62        try:
     63            importers = find_package_importers(part, importers)
     64        except ImportError,e:
     65            if os.path.basename(os.getcwd()) != part:
     66                raise e
    5567
    5668    while parts:
    5769        part = parts.pop()
    58         f, path, descr = imp.find_module(part, path and [path] or None)
    59     return path
     70        importers = find_package_importers(part, importers)
     71    return importers
    6072
    6173def load_command_class(app_name, name):
    6274    """
    def get_commands():  
    91103    """
    92104    global _commands
    93105    if _commands is None:
    94         _commands = dict([(name, 'django.core') for name in find_commands(__path__[0])])
     106        _commands = dict(
     107            [ (name, 'django.core')
     108                for name in find_commands(
     109                    find_importers(
     110                        [ os.path.join(p, 'commands') for p in __path__ ]))])
    95111
    96112        # Find the installed apps
    97113        try:
    def get_commands():  
    103119        # Find and load the management module for each installed app.
    104120        for app_name in apps:
    105121            try:
    106                 path = find_management_module(app_name)
     122                importers = find_commands_importers(app_name)
    107123                _commands.update(dict([(name, app_name)
    108                                        for name in find_commands(path)]))
     124                                       for name in find_commands(importers)]))
    109125            except ImportError:
    110126                pass # No management module - ignore this app
    111127
  • django/utils/importlib.py

    diff --git a/django/utils/importlib.py b/django/utils/importlib.py
    index ef4d0e4..db6e642 100644
    a b  
    11# Taken from Python 2.7 with permission from/by the original author.
    22import sys
     3import imp
     4import pkgutil
     5import os
     6
     7try:
     8    import zipimport
     9
     10    class ZipImporter(zipimport.zipimporter):
     11       
     12        # taken from pkgutil.iter_zipimport_modules
     13        def get_filename(self, fullname):
     14            dirlist = zipimport._zip_directory_cache[self.archive].keys()
     15            dirlist.sort()
     16            _prefix = self.prefix
     17            plen = len(_prefix)
     18            import inspect
     19            for filename in dirlist:
     20                if not filename.startswith(_prefix):
     21                    continue
     22               
     23                fn = filename[plen:].split(os.sep)
     24               
     25                if len(fn)==2 and (fn[0] == fullname) and fn[1].startswith('__init__.py'):
     26                    return os.path.join(self.archive, filename)
     27               
     28                if len(fn)!=1:
     29                    continue
     30               
     31                modname = inspect.getmodulename(fn[0])
     32                if modname=='__init__':
     33                    continue
     34                   
     35                if modname and '.' not in modname and (modname==fullname):
     36                    return fullname
     37
     38    if hasattr(zipimport.zipimporter, 'get_filename'):
     39        zipimport = None
     40
     41except ImportError:
     42    zipimport = None
     43
    344
    445def _resolve_name(name, package, level):
    546    """Return the absolute name of the module to be imported."""
    def import_module(name, package=None):  
    3475        name = _resolve_name(name[level:], package, level)
    3576    __import__(name)
    3677    return sys.modules[name]
     78
     79
     80
     81def find_importers(path=None):
     82    importers = []
     83
     84    if path is None:
     85        path = sys.path
     86        importers += sys.meta_path
     87
     88    for path_item in path:
     89        importer = pkgutil.get_importer(path_item)
     90       
     91        if zipimport and isinstance(importer, zipimport.zipimporter):
     92            if importer.prefix:
     93                archivepath = os.path.join(importer.archive, importer.prefix)
     94            else:
     95                archivepath = importer.archive
     96
     97            importer = ZipImporter(os.path.join(archivepath))
     98
     99        importers.append(importer)
     100       
     101    return importers
     102
     103
     104
     105def find_package_importers(name, importers):
     106    new_importers = []
     107
     108    for importer in importers:
     109        try:
     110            loader = importer.find_module(name)
     111           
     112            if loader is not None and loader.is_package(name):
     113                filename = os.path.dirname(loader.get_filename(name))
     114                new_importers.append(importer.__class__(filename))
     115        except ImportError:
     116            pass
     117
     118    return new_importers
     119
     120
  • 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/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..1cd7708 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 = [test_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        test_dir = os.path.dirname(os.path.dirname(__file__))
     1501        settings_file = open(os.path.join(test_dir, 'settings.py'), 'a')
     1502        settings_file.write('import _addsitedir')
     1503        settings_file.close()
     1504       
     1505    def tearDown(self):
     1506        self.remove_settings('settings.py')
     1507
     1508    def test_help(self):
     1509        out, err = self.run_manage(['help'])
     1510        self.assertNoOutput(err)
     1511        self.assertOutput(out, "nons_app_command1")
     1512        self.assertOutput(out, "app1_command1")
     1513        self.assertOutput(out, "app2_command1")
     1514        self.assertOutput(out, "app3_command1")
     1515        self.assertOutput(out, "egg_command")
     1516
     1517    def test_nons_app(self):
     1518        args = ['nons_app_command1']
     1519        out, err = self.run_manage(args)
     1520        self.assertNoOutput(err)
     1521        self.assertOutput(out, "EXECUTE:nons_app_command1")
     1522
     1523    def test_nsapps(self):
     1524        args = ['app1_command1']
     1525        out, err = self.run_manage(args)
     1526        self.assertNoOutput(err)
     1527        self.assertOutput(out, "EXECUTE:app1_command1")
     1528
     1529        args = ['app2_command1']
     1530        out, err = self.run_manage(args)
     1531        self.assertNoOutput(err)
     1532        self.assertOutput(out, "EXECUTE:app2_command1")
     1533
     1534    def test_exapps(self):
     1535        args = ['app3_command1']
     1536        out, err = self.run_manage(args)
     1537        self.assertNoOutput(err)
     1538        self.assertOutput(out, "EXECUTE:app3_command1")
     1539
     1540    def test_exapps(self):
     1541        args = ['egg_command']
     1542        out, err = self.run_manage(args)
     1543        self.assertNoOutput(err)
     1544        self.assertOutput(out, "EXECUTE:egg_command")
     1545
     1546
     1547class PreloadedNamespacePackagedApps(AdminScriptTestCase):
     1548    def setUp(self):
     1549        self.write_settings('settings.py', apps=['nsapps.contrib.app1','nsapps.contrib.app2'])
     1550        test_dir = os.path.dirname(os.path.dirname(__file__))
     1551        settings_file = open(os.path.join(test_dir, 'settings.py'), 'a')
     1552        settings_file.write('import nsapps')
     1553        settings_file.close()
     1554       
     1555    def tearDown(self):
     1556        self.remove_settings('settings.py')
     1557
     1558    def test_help(self):
     1559        out, err = self.run_manage(['help'])
     1560        self.assertNoOutput(err)
     1561        self.assertOutput(out, "app1_command1")
     1562        self.assertOutput(out, "app2_command1")
     1563
     1564
     1565    def test_nsapps(self):
     1566        args = ['app1_command1']
     1567        out, err = self.run_manage(args)
     1568        self.assertNoOutput(err)
     1569        self.assertOutput(out, "EXECUTE:app1_command1")
     1570
     1571        args = ['app2_command1']
     1572        out, err = self.run_manage(args)
     1573        self.assertNoOutput(err)
     1574        self.assertOutput(out, "EXECUTE:app2_command1")
     1575
     1576
     1577
     1578
Back to Top