mirror of
https://github.com/django/django.git
synced 2025-11-03 05:13:23 +00:00
Fixed #17042 -- Extended startproject and startapp management commands to better handle custom app and project templates. Many thanks to Preston Holmes for his initial patch and Alex Gaynor, Carl Meyer, Donald Stufft, Jacob Kaplan-Moss and Julien Phalip for code reviewing.
* Added ability to pass the project or app directory path as the second argument * Added ``--template`` option for specifying custom project and app templates * Cleaned up admin_scripts tests a little while I was there git-svn-id: http://code.djangoproject.com/svn/django/trunk@17246 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
98c974c70b
commit
a9a0f0b03f
29 changed files with 996 additions and 266 deletions
69
tests/regressiontests/utils/archive.py
Normal file
69
tests/regressiontests/utils/archive.py
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
import os
|
||||
import shutil
|
||||
import tempfile
|
||||
from django.utils import unittest
|
||||
|
||||
from django.utils.archive import Archive, extract
|
||||
|
||||
|
||||
TEST_DIR = os.path.join(os.path.dirname(__file__), 'archives')
|
||||
|
||||
|
||||
class ArchiveTester(object):
|
||||
archive = None
|
||||
|
||||
def setUp(self):
|
||||
"""
|
||||
Create temporary directory for testing extraction.
|
||||
"""
|
||||
self.old_cwd = os.getcwd()
|
||||
self.tmpdir = tempfile.mkdtemp()
|
||||
self.addCleanup(shutil.rmtree, self.tmpdir)
|
||||
self.archive_path = os.path.join(TEST_DIR, self.archive)
|
||||
# Always start off in TEST_DIR.
|
||||
os.chdir(TEST_DIR)
|
||||
|
||||
def tearDown(self):
|
||||
os.chdir(self.old_cwd)
|
||||
|
||||
def test_extract_method(self):
|
||||
Archive(self.archive).extract(self.tmpdir)
|
||||
self.check_files(self.tmpdir)
|
||||
|
||||
def test_extract_method_no_to_path(self):
|
||||
os.chdir(self.tmpdir)
|
||||
Archive(self.archive_path).extract()
|
||||
self.check_files(self.tmpdir)
|
||||
|
||||
def test_extract_function(self):
|
||||
extract(self.archive_path, self.tmpdir)
|
||||
self.check_files(self.tmpdir)
|
||||
|
||||
def test_extract_function_no_to_path(self):
|
||||
os.chdir(self.tmpdir)
|
||||
extract(self.archive_path)
|
||||
self.check_files(self.tmpdir)
|
||||
|
||||
def check_files(self, tmpdir):
|
||||
self.assertTrue(os.path.isfile(os.path.join(self.tmpdir, '1')))
|
||||
self.assertTrue(os.path.isfile(os.path.join(self.tmpdir, '2')))
|
||||
self.assertTrue(os.path.isfile(os.path.join(self.tmpdir, 'foo', '1')))
|
||||
self.assertTrue(os.path.isfile(os.path.join(self.tmpdir, 'foo', '2')))
|
||||
self.assertTrue(os.path.isfile(os.path.join(self.tmpdir, 'foo', 'bar', '1')))
|
||||
self.assertTrue(os.path.isfile(os.path.join(self.tmpdir, 'foo', 'bar', '2')))
|
||||
|
||||
|
||||
class TestZip(ArchiveTester, unittest.TestCase):
|
||||
archive = 'foobar.zip'
|
||||
|
||||
|
||||
class TestTar(ArchiveTester, unittest.TestCase):
|
||||
archive = 'foobar.tar'
|
||||
|
||||
|
||||
class TestGzipTar(ArchiveTester, unittest.TestCase):
|
||||
archive = 'foobar.tar.gz'
|
||||
|
||||
|
||||
class TestBzip2Tar(ArchiveTester, unittest.TestCase):
|
||||
archive = 'foobar.tar.bz2'
|
||||
BIN
tests/regressiontests/utils/archives/foobar.tar
Normal file
BIN
tests/regressiontests/utils/archives/foobar.tar
Normal file
Binary file not shown.
BIN
tests/regressiontests/utils/archives/foobar.tar.bz2
Normal file
BIN
tests/regressiontests/utils/archives/foobar.tar.bz2
Normal file
Binary file not shown.
BIN
tests/regressiontests/utils/archives/foobar.tar.gz
Normal file
BIN
tests/regressiontests/utils/archives/foobar.tar.gz
Normal file
Binary file not shown.
BIN
tests/regressiontests/utils/archives/foobar.zip
Normal file
BIN
tests/regressiontests/utils/archives/foobar.zip
Normal file
Binary file not shown.
|
|
@ -24,3 +24,4 @@ from .baseconv import TestBaseConv
|
|||
from .jslex import JsTokensTest, JsToCForGettextTest
|
||||
from .ipv6 import TestUtilsIPv6
|
||||
from .timezone import TimezoneTests
|
||||
from .archive import TestZip, TestTar, TestGzipTar, TestBzip2Tar
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue