1 """Tests for distutils.command.bdist_dumb."""
7 # zlib is not used here, but if it's not available
8 # test_simple_built will fail
14 from distutils
.core
import Distribution
15 from distutils
.command
.bdist_dumb
import bdist_dumb
16 from distutils
.tests
import support
19 from distutils.core import setup
22 setup(name='foo', version='0.1', py_modules=['foo'],
23 url='xxx', author='xxx', author_email='xxx')
27 class BuildDumbTestCase(support
.TempdirManager
,
28 support
.LoggingSilencer
,
33 super(BuildDumbTestCase
, self
).setUp()
34 self
.old_location
= os
.getcwd()
35 self
.old_sys_argv
= sys
.argv
, sys
.argv
[:]
38 os
.chdir(self
.old_location
)
39 sys
.argv
= self
.old_sys_argv
[0]
40 sys
.argv
[:] = self
.old_sys_argv
[1]
41 super(BuildDumbTestCase
, self
).tearDown()
43 @unittest.skipUnless(zlib
, "requires zlib")
44 def test_simple_built(self
):
46 # let's create a simple package
47 tmp_dir
= self
.mkdtemp()
48 pkg_dir
= os
.path
.join(tmp_dir
, 'foo')
50 self
.write_file((pkg_dir
, 'setup.py'), SETUP_PY
)
51 self
.write_file((pkg_dir
, 'foo.py'), '#')
52 self
.write_file((pkg_dir
, 'MANIFEST.in'), 'include foo.py')
53 self
.write_file((pkg_dir
, 'README'), '')
55 dist
= Distribution({'name': 'foo', 'version': '0.1',
56 'py_modules': ['foo'],
57 'url': 'xxx', 'author': 'xxx',
58 'author_email': 'xxx'})
59 dist
.script_name
= 'setup.py'
62 sys
.argv
= ['setup.py']
63 cmd
= bdist_dumb(dist
)
65 # so the output is the same no matter
66 # what is the platform
69 cmd
.ensure_finalized()
73 dist_created
= os
.listdir(os
.path
.join(pkg_dir
, 'dist'))
74 base
= "%s.%s" % (dist
.get_fullname(), cmd
.plat_name
)
76 base
= base
.replace(':', '-')
78 wanted
= ['%s.zip' % base
]
79 self
.assertEquals(dist_created
, wanted
)
81 # now let's check what we have in the zip file
84 def test_finalize_options(self
):
85 pkg_dir
, dist
= self
.create_dist()
87 cmd
= bdist_dumb(dist
)
88 self
.assertEquals(cmd
.bdist_dir
, None)
89 cmd
.finalize_options()
91 # bdist_dir is initialized to bdist_base/dumb if not set
92 base
= cmd
.get_finalized_command('bdist').bdist_base
93 self
.assertEquals(cmd
.bdist_dir
, os
.path
.join(base
, 'dumb'))
95 # the format is set to a default value depending on the os.name
96 default
= cmd
.default_format
[os
.name
]
97 self
.assertEquals(cmd
.format
, default
)
100 return unittest
.makeSuite(BuildDumbTestCase
)
102 if __name__
== '__main__':
103 test_support
.run_unittest(test_suite())