pypy-postgresql / lib-python / 2.7 / distutils / tests /

"""Tests for distutils.command.bdist_dumb."""

import unittest
import sys
import os

# zlib is not used here, but if it's not available
# test_simple_built will fail
    import zlib
except ImportError:
    zlib = None

from test.test_support import run_unittest

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')


class BuildDumbTestCase(support.TempdirManager,

    def setUp(self):
        super(BuildDumbTestCase, self).setUp()
        self.old_location = os.getcwd()
        self.old_sys_argv = sys.argv, sys.argv[:]

    def tearDown(self):
        sys.argv = self.old_sys_argv[0]
        sys.argv[:] = self.old_sys_argv[1]
        super(BuildDumbTestCase, self).tearDown()

    @unittest.skipUnless(zlib, "requires zlib")
    def test_simple_built(self):

        # let's create a simple package
        tmp_dir = self.mkdtemp()
        pkg_dir = os.path.join(tmp_dir, 'foo')
        self.write_file((pkg_dir, ''), SETUP_PY)
        self.write_file((pkg_dir, ''), '#')
        self.write_file((pkg_dir, ''), 'include')
        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 = ''

        sys.argv = ['']
        cmd = bdist_dumb(dist)

        # so the output is the same no matter
        # what is the platform
        cmd.format = 'zip'


        # see what we have
        dist_created = os.listdir(os.path.join(pkg_dir, 'dist'))
        base = "%s.%s" % (dist.get_fullname(), cmd.plat_name)
        if == 'os2':
            base = base.replace(':', '-')

        wanted = ['' % base]
        self.assertEqual(dist_created, wanted)

        # now let's check what we have in the zip file
        # XXX to be done

    def test_finalize_options(self):
        pkg_dir, dist = self.create_dist()
        cmd = bdist_dumb(dist)
        self.assertEqual(cmd.bdist_dir, None)

        # bdist_dir is initialized to bdist_base/dumb if not set
        base = cmd.get_finalized_command('bdist').bdist_base
        self.assertEqual(cmd.bdist_dir, os.path.join(base, 'dumb'))

        # the format is set to a default value depending on the
        default = cmd.default_format[]
        self.assertEqual(cmd.format, default)

def test_suite():
    return unittest.makeSuite(BuildDumbTestCase)

if __name__ == '__main__':
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.