2009-02-23 08:47:55 -04:00
|
|
|
"""Tests for distutils.command.bdist_dumb."""
|
|
|
|
|
|
|
|
import os
|
2011-11-02 14:05:41 -03:00
|
|
|
import sys
|
|
|
|
import zipfile
|
|
|
|
import unittest
|
Merged revisions 86236,86240,86332,86340,87271,87273,87447 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
The missing NEWS entries correspond to changes that were made before 3.1.3, but
I think it’s not usual to edit entries of released versions, so I put them at
the top.
........
r86236 | eric.araujo | 2010-11-06 03:44:43 +0100 (sam., 06 nov. 2010) | 2 lines
Make sure each test can be run standalone (./python Lib/distutils/tests/x.py)
........
r86240 | eric.araujo | 2010-11-06 05:11:59 +0100 (sam., 06 nov. 2010) | 2 lines
Prevent ResourceWarnings in test_gettext
........
r86332 | eric.araujo | 2010-11-08 19:15:17 +0100 (lun., 08 nov. 2010) | 4 lines
Add missing NEWS entry for a fix committed by Senthil.
All recent modifications to distutils should now be covered in NEWS.
........
r86340 | eric.araujo | 2010-11-08 22:48:23 +0100 (lun., 08 nov. 2010) | 2 lines
This was actually fixed for the previous alpha.
........
r87271 | eric.araujo | 2010-12-15 20:09:58 +0100 (mer., 15 déc. 2010) | 2 lines
Improve trace documentation (#9264). Patch by Eli Bendersky.
........
r87273 | eric.araujo | 2010-12-15 20:30:15 +0100 (mer., 15 déc. 2010) | 2 lines
Use nested method directives, rewrap long lines, fix whitespace.
........
r87447 | eric.araujo | 2010-12-23 20:13:05 +0100 (jeu., 23 déc. 2010) | 2 lines
Fix typo in superclass method name
........
2011-02-02 17:38:37 -04:00
|
|
|
from test.support import run_unittest
|
2009-02-23 08:47:55 -04:00
|
|
|
|
|
|
|
from distutils.core import Distribution
|
|
|
|
from distutils.command.bdist_dumb import bdist_dumb
|
|
|
|
from distutils.tests import support
|
|
|
|
|
|
|
|
SETUP_PY = """\
|
|
|
|
from distutils.core import setup
|
|
|
|
import foo
|
|
|
|
|
|
|
|
setup(name='foo', version='0.1', py_modules=['foo'],
|
|
|
|
url='xxx', author='xxx', author_email='xxx')
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
2011-03-15 17:02:59 -03:00
|
|
|
try:
|
|
|
|
import zlib
|
|
|
|
ZLIB_SUPPORT = True
|
|
|
|
except ImportError:
|
|
|
|
ZLIB_SUPPORT = False
|
|
|
|
|
|
|
|
|
2009-02-23 08:47:55 -04:00
|
|
|
class BuildDumbTestCase(support.TempdirManager,
|
|
|
|
support.LoggingSilencer,
|
2009-10-18 09:41:30 -03:00
|
|
|
support.EnvironGuard,
|
2009-02-23 08:47:55 -04:00
|
|
|
unittest.TestCase):
|
|
|
|
|
|
|
|
def setUp(self):
|
2009-05-29 06:14:04 -03:00
|
|
|
super(BuildDumbTestCase, self).setUp()
|
2009-02-23 08:47:55 -04:00
|
|
|
self.old_location = os.getcwd()
|
2009-10-18 09:41:30 -03:00
|
|
|
self.old_sys_argv = sys.argv, sys.argv[:]
|
2009-02-23 08:47:55 -04:00
|
|
|
|
|
|
|
def tearDown(self):
|
|
|
|
os.chdir(self.old_location)
|
2009-10-18 09:41:30 -03:00
|
|
|
sys.argv = self.old_sys_argv[0]
|
|
|
|
sys.argv[:] = self.old_sys_argv[1]
|
2009-05-29 06:14:04 -03:00
|
|
|
super(BuildDumbTestCase, self).tearDown()
|
2009-02-23 08:47:55 -04:00
|
|
|
|
2011-03-15 17:02:59 -03:00
|
|
|
@unittest.skipUnless(ZLIB_SUPPORT, 'Need zlib support to run')
|
2009-02-23 08:47:55 -04:00
|
|
|
def test_simple_built(self):
|
|
|
|
|
|
|
|
# let's create a simple package
|
|
|
|
tmp_dir = self.mkdtemp()
|
|
|
|
pkg_dir = os.path.join(tmp_dir, 'foo')
|
|
|
|
os.mkdir(pkg_dir)
|
|
|
|
self.write_file((pkg_dir, 'setup.py'), SETUP_PY)
|
|
|
|
self.write_file((pkg_dir, 'foo.py'), '#')
|
|
|
|
self.write_file((pkg_dir, 'MANIFEST.in'), 'include foo.py')
|
|
|
|
self.write_file((pkg_dir, 'README'), '')
|
|
|
|
|
|
|
|
dist = Distribution({'name': 'foo', 'version': '0.1',
|
|
|
|
'py_modules': ['foo'],
|
|
|
|
'url': 'xxx', 'author': 'xxx',
|
|
|
|
'author_email': 'xxx'})
|
|
|
|
dist.script_name = 'setup.py'
|
|
|
|
os.chdir(pkg_dir)
|
|
|
|
|
|
|
|
sys.argv = ['setup.py']
|
|
|
|
cmd = bdist_dumb(dist)
|
|
|
|
|
|
|
|
# so the output is the same no matter
|
|
|
|
# what is the platform
|
|
|
|
cmd.format = 'zip'
|
|
|
|
|
|
|
|
cmd.ensure_finalized()
|
|
|
|
cmd.run()
|
|
|
|
|
|
|
|
# see what we have
|
|
|
|
dist_created = os.listdir(os.path.join(pkg_dir, 'dist'))
|
2011-11-02 14:05:41 -03:00
|
|
|
base = "%s.%s.zip" % (dist.get_fullname(), cmd.plat_name)
|
2009-02-23 08:47:55 -04:00
|
|
|
|
2011-11-02 14:05:41 -03:00
|
|
|
self.assertEqual(dist_created, [base])
|
2009-02-23 08:47:55 -04:00
|
|
|
|
|
|
|
# now let's check what we have in the zip file
|
2011-11-02 14:05:41 -03:00
|
|
|
fp = zipfile.ZipFile(os.path.join('dist', base))
|
|
|
|
try:
|
|
|
|
contents = fp.namelist()
|
|
|
|
finally:
|
|
|
|
fp.close()
|
|
|
|
|
|
|
|
contents = sorted(os.path.basename(fn) for fn in contents)
|
2013-03-16 14:48:51 -03:00
|
|
|
wanted = ['foo-0.1-py%s.%s.egg-info' % sys.version_info[:2], 'foo.py']
|
|
|
|
if not sys.dont_write_bytecode:
|
2013-06-15 13:59:53 -03:00
|
|
|
wanted.append('foo.%s.pyc' % sys.implementation.cache_tag)
|
2011-11-02 14:05:41 -03:00
|
|
|
self.assertEqual(contents, sorted(wanted))
|
2009-02-23 08:47:55 -04:00
|
|
|
|
|
|
|
def test_suite():
|
|
|
|
return unittest.makeSuite(BuildDumbTestCase)
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
Merged revisions 86236,86240,86332,86340,87271,87273,87447 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
The missing NEWS entries correspond to changes that were made before 3.1.3, but
I think it’s not usual to edit entries of released versions, so I put them at
the top.
........
r86236 | eric.araujo | 2010-11-06 03:44:43 +0100 (sam., 06 nov. 2010) | 2 lines
Make sure each test can be run standalone (./python Lib/distutils/tests/x.py)
........
r86240 | eric.araujo | 2010-11-06 05:11:59 +0100 (sam., 06 nov. 2010) | 2 lines
Prevent ResourceWarnings in test_gettext
........
r86332 | eric.araujo | 2010-11-08 19:15:17 +0100 (lun., 08 nov. 2010) | 4 lines
Add missing NEWS entry for a fix committed by Senthil.
All recent modifications to distutils should now be covered in NEWS.
........
r86340 | eric.araujo | 2010-11-08 22:48:23 +0100 (lun., 08 nov. 2010) | 2 lines
This was actually fixed for the previous alpha.
........
r87271 | eric.araujo | 2010-12-15 20:09:58 +0100 (mer., 15 déc. 2010) | 2 lines
Improve trace documentation (#9264). Patch by Eli Bendersky.
........
r87273 | eric.araujo | 2010-12-15 20:30:15 +0100 (mer., 15 déc. 2010) | 2 lines
Use nested method directives, rewrap long lines, fix whitespace.
........
r87447 | eric.araujo | 2010-12-23 20:13:05 +0100 (jeu., 23 déc. 2010) | 2 lines
Fix typo in superclass method name
........
2011-02-02 17:38:37 -04:00
|
|
|
run_unittest(test_suite())
|