OLD | NEW |
1 """Tests for distutils.command.bdist_dumb.""" | 1 """Tests for distutils.command.bdist_dumb.""" |
2 | 2 |
3 import unittest | 3 import unittest |
4 import sys | 4 import sys |
5 import os | 5 import os |
6 | 6 |
| 7 try: |
| 8 import zlib |
| 9 except ImportError: |
| 10 zlib = None |
| 11 |
7 from distutils.core import Distribution | 12 from distutils.core import Distribution |
8 from distutils.command.bdist_dumb import bdist_dumb | 13 from distutils.command.bdist_dumb import bdist_dumb |
9 from distutils.tests import support | 14 from distutils.tests import support |
10 | 15 |
11 SETUP_PY = """\ | 16 SETUP_PY = """\ |
12 from distutils.core import setup | 17 from distutils.core import setup |
13 import foo | 18 import foo |
14 | 19 |
15 setup(name='foo', version='0.1', py_modules=['foo'], | 20 setup(name='foo', version='0.1', py_modules=['foo'], |
16 url='xxx', author='xxx', author_email='xxx') | 21 url='xxx', author='xxx', author_email='xxx') |
17 | 22 |
18 """ | 23 """ |
19 | 24 |
20 class BuildDumbTestCase(support.TempdirManager, | 25 class BuildDumbTestCase(support.TempdirManager, |
21 support.LoggingSilencer, | 26 support.LoggingSilencer, |
22 unittest.TestCase): | 27 unittest.TestCase): |
23 | 28 |
24 def setUp(self): | 29 def setUp(self): |
25 super(BuildDumbTestCase, self).setUp() | 30 super(BuildDumbTestCase, self).setUp() |
26 self.old_location = os.getcwd() | 31 self.old_location = os.getcwd() |
27 self.old_sys_argv = sys.argv[:] | 32 self.old_sys_argv = sys.argv[:] |
28 | 33 |
29 def tearDown(self): | 34 def tearDown(self): |
30 os.chdir(self.old_location) | 35 os.chdir(self.old_location) |
31 sys.argv = self.old_sys_argv[:] | 36 sys.argv = self.old_sys_argv[:] |
32 super(BuildDumbTestCase, self).tearDown() | 37 super(BuildDumbTestCase, self).tearDown() |
33 | 38 |
| 39 @unittest.skipUnless(zlib, "requires zlib") |
34 def test_simple_built(self): | 40 def test_simple_built(self): |
35 | 41 |
36 # let's create a simple package | 42 # let's create a simple package |
37 tmp_dir = self.mkdtemp() | 43 tmp_dir = self.mkdtemp() |
38 pkg_dir = os.path.join(tmp_dir, 'foo') | 44 pkg_dir = os.path.join(tmp_dir, 'foo') |
39 os.mkdir(pkg_dir) | 45 os.mkdir(pkg_dir) |
40 self.write_file((pkg_dir, 'setup.py'), SETUP_PY) | 46 self.write_file((pkg_dir, 'setup.py'), SETUP_PY) |
41 self.write_file((pkg_dir, 'foo.py'), '#') | 47 self.write_file((pkg_dir, 'foo.py'), '#') |
42 self.write_file((pkg_dir, 'MANIFEST.in'), 'include foo.py') | 48 self.write_file((pkg_dir, 'MANIFEST.in'), 'include foo.py') |
43 self.write_file((pkg_dir, 'README'), '') | 49 self.write_file((pkg_dir, 'README'), '') |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 | 90 |
85 # the format is set to a default value depending on the os.name | 91 # the format is set to a default value depending on the os.name |
86 default = cmd.default_format[os.name] | 92 default = cmd.default_format[os.name] |
87 self.assertEquals(cmd.format, default) | 93 self.assertEquals(cmd.format, default) |
88 | 94 |
89 def test_suite(): | 95 def test_suite(): |
90 return unittest.makeSuite(BuildDumbTestCase) | 96 return unittest.makeSuite(BuildDumbTestCase) |
91 | 97 |
92 if __name__ == '__main__': | 98 if __name__ == '__main__': |
93 test_support.run_unittest(test_suite()) | 99 test_support.run_unittest(test_suite()) |
OLD | NEW |