Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add regression test for ticket #18685, which tests that loading

management commands from two different setuptools packages, that are in
the same parent module works correctly.
  • Loading branch information...
commit 6c17f767968def3a6c7afff2492ad23e339ef884 1 parent be5eb95
@cberner cberner authored
Showing with 43 additions and 0 deletions.
  1. 0  tests/regressiontests/admin_scripts/find_command_submodules/project-A/mypackage/A/__init__.py
  2. 0  tests/regressiontests/admin_scripts/find_command_submodules/project-A/mypackage/A/management/__init__.py
  3. 0  ...regressiontests/admin_scripts/find_command_submodules/project-A/mypackage/A/management/commands/__init__.py
  4. +5 −0 ...egressiontests/admin_scripts/find_command_submodules/project-A/mypackage/A/management/commands/command_A.py
  5. +2 −0  tests/regressiontests/admin_scripts/find_command_submodules/project-A/mypackage/__init__.py
  6. 0  tests/regressiontests/admin_scripts/find_command_submodules/project-B/mypackage/B/__init__.py
  7. 0  tests/regressiontests/admin_scripts/find_command_submodules/project-B/mypackage/B/management/__init__.py
  8. 0  ...regressiontests/admin_scripts/find_command_submodules/project-B/mypackage/B/management/commands/__init__.py
  9. +5 −0 ...egressiontests/admin_scripts/find_command_submodules/project-B/mypackage/B/management/commands/command_B.py
  10. +2 −0  tests/regressiontests/admin_scripts/find_command_submodules/project-B/mypackage/__init__.py
  11. +4 −0 tests/regressiontests/admin_scripts/find_command_submodules/site-packages/easy-install.pth
  12. +2 −0  tests/regressiontests/admin_scripts/find_command_submodules/site-packages/mypackage-A.egg-link
  13. +2 −0  tests/regressiontests/admin_scripts/find_command_submodules/site-packages/mypackage-B.egg-link
  14. +21 −0 tests/regressiontests/admin_scripts/tests.py
View
0  tests/regressiontests/admin_scripts/find_command_submodules/project-A/mypackage/A/__init__.py
No changes.
View
0  tests/regressiontests/admin_scripts/find_command_submodules/project-A/mypackage/A/management/__init__.py
No changes.
View
0  ...ressiontests/admin_scripts/find_command_submodules/project-A/mypackage/A/management/commands/__init__.py
No changes.
View
5 ...essiontests/admin_scripts/find_command_submodules/project-A/mypackage/A/management/commands/command_A.py
@@ -0,0 +1,5 @@
+from django.core.management.base import BaseCommand
+
+class Command(BaseCommand):
+ def handle(self, *args, **options):
+ print "Command A"
View
2  tests/regressiontests/admin_scripts/find_command_submodules/project-A/mypackage/__init__.py
@@ -0,0 +1,2 @@
+from pkgutil import extend_path
+__path__ = extend_path(__path__, __name__)
View
0  tests/regressiontests/admin_scripts/find_command_submodules/project-B/mypackage/B/__init__.py
No changes.
View
0  tests/regressiontests/admin_scripts/find_command_submodules/project-B/mypackage/B/management/__init__.py
No changes.
View
0  ...ressiontests/admin_scripts/find_command_submodules/project-B/mypackage/B/management/commands/__init__.py
No changes.
View
5 ...essiontests/admin_scripts/find_command_submodules/project-B/mypackage/B/management/commands/command_B.py
@@ -0,0 +1,5 @@
+from django.core.management.base import BaseCommand
+
+class Command(BaseCommand):
+ def handle(self, *args, **options):
+ print "Command B"
View
2  tests/regressiontests/admin_scripts/find_command_submodules/project-B/mypackage/__init__.py
@@ -0,0 +1,2 @@
+from pkgutil import extend_path
+__path__ = extend_path(__path__, __name__)
View
4 tests/regressiontests/admin_scripts/find_command_submodules/site-packages/easy-install.pth
@@ -0,0 +1,4 @@
+import sys; sys.__plen = len(sys.path)
+../project-B
+../project-A
+import sys; new=sys.path[sys.__plen:]; del sys.path[sys.__plen:]; p=getattr(sys,'__egginsert',0); sys.path[p:p]=new; sys.__egginsert = p+len(new)
View
2  tests/regressiontests/admin_scripts/find_command_submodules/site-packages/mypackage-A.egg-link
@@ -0,0 +1,2 @@
+../project-A
+.
View
2  tests/regressiontests/admin_scripts/find_command_submodules/site-packages/mypackage-B.egg-link
@@ -0,0 +1,2 @@
+../project-B
+.
View
21 tests/regressiontests/admin_scripts/tests.py
@@ -10,6 +10,7 @@
import socket
import subprocess
import sys
+import site
from django import conf, bin, get_version
from django.conf import settings
@@ -17,6 +18,7 @@
from django.test.simple import DjangoTestSuiteRunner
from django.utils import unittest
from django.test import LiveServerTestCase
+from django.core.management import find_management_module
test_dir = os.path.dirname(os.path.dirname(__file__))
@@ -1094,6 +1096,25 @@ def test_liveserver(self):
else:
del os.environ['DJANGO_LIVE_TEST_SERVER_ADDRESS']
+class FindCommandTest(AdminScriptTestCase):
+ def setUp(self):
+ self.old_path = sys.path
+ #Add the package directories to the sys path, like setuptools would do,
+ #when running the 'develop' command via an egg-link
+ site.addsitedir(os.path.join(os.path.dirname(__file__), "find_command_submodules/site-packages"))
+
+ def test_modules_from_different_setuptools_packages(self):
+ """Test for ticket 18685. Check that multiple modules in the same package,
+ installed from different setuptools packages, load their management commands
+ correctly.
+ """
+ module_A_path = find_management_module("mypackage.A")
+ self.assertTrue(module_A_path.endswith("project-A/mypackage/A/management"), module_A_path)
+ module_B_path = find_management_module("mypackage.B")
+ self.assertTrue(module_B_path.endswith("project-B/mypackage/B/management"), module_B_path)
+
+ def tearDown(self):
+ sys.path = self.old_path
class ManageRunserver(AdminScriptTestCase):
def setUp(self):
Please sign in to comment.
Something went wrong with that request. Please try again.