]>
git.proxmox.com Git - mirror_edk2.git/blob - AppPkg/Applications/Python/Python-2.7.2/Lib/distutils/tests/test_bdist_rpm.py
a85f22471689df78c5bba482c4e37ef4e2d603e0
1 """Tests for distutils.command.bdist_rpm."""
9 from test
.test_support
import run_unittest
11 from distutils
.core
import Distribution
12 from distutils
.command
.bdist_rpm
import bdist_rpm
13 from distutils
.tests
import support
14 from distutils
.spawn
import find_executable
15 from distutils
import spawn
16 from distutils
.errors
import DistutilsExecError
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 BuildRpmTestCase(support
.TempdirManager
,
28 support
.LoggingSilencer
,
32 super(BuildRpmTestCase
, self
).setUp()
33 self
.old_location
= os
.getcwd()
34 self
.old_sys_argv
= sys
.argv
, sys
.argv
[:]
37 os
.chdir(self
.old_location
)
38 sys
.argv
= self
.old_sys_argv
[0]
39 sys
.argv
[:] = self
.old_sys_argv
[1]
40 super(BuildRpmTestCase
, self
).tearDown()
44 # XXX I am unable yet to make this test work without
45 # spurious sdtout/stderr output under Mac OS X
46 if sys
.platform
!= 'linux2':
49 # this test will run only if the rpm commands are found
50 if (find_executable('rpm') is None or
51 find_executable('rpmbuild') is None):
54 # let's create a package
55 tmp_dir
= self
.mkdtemp()
56 pkg_dir
= os
.path
.join(tmp_dir
, 'foo')
58 self
.write_file((pkg_dir
, 'setup.py'), SETUP_PY
)
59 self
.write_file((pkg_dir
, 'foo.py'), '#')
60 self
.write_file((pkg_dir
, 'MANIFEST.in'), 'include foo.py')
61 self
.write_file((pkg_dir
, 'README'), '')
63 dist
= Distribution({'name': 'foo', 'version': '0.1',
64 'py_modules': ['foo'],
65 'url': 'xxx', 'author': 'xxx',
66 'author_email': 'xxx'})
67 dist
.script_name
= 'setup.py'
70 sys
.argv
= ['setup.py']
74 # running in quiet mode
76 cmd
.ensure_finalized()
79 dist_created
= os
.listdir(os
.path
.join(pkg_dir
, 'dist'))
80 self
.assertTrue('foo-0.1-1.noarch.rpm' in dist_created
)
82 def test_no_optimize_flag(self
):
84 # XXX I am unable yet to make this test work without
85 # spurious sdtout/stderr output under Mac OS X
86 if sys
.platform
!= 'linux2':
89 # http://bugs.python.org/issue1533164
90 # this test will run only if the rpm command is found
91 if (find_executable('rpm') is None or
92 find_executable('rpmbuild') is None):
95 # let's create a package that brakes bdist_rpm
96 tmp_dir
= self
.mkdtemp()
97 pkg_dir
= os
.path
.join(tmp_dir
, 'foo')
99 self
.write_file((pkg_dir
, 'setup.py'), SETUP_PY
)
100 self
.write_file((pkg_dir
, 'foo.py'), '#')
101 self
.write_file((pkg_dir
, 'MANIFEST.in'), 'include foo.py')
102 self
.write_file((pkg_dir
, 'README'), '')
104 dist
= Distribution({'name': 'foo', 'version': '0.1',
105 'py_modules': ['foo'],
106 'url': 'xxx', 'author': 'xxx',
107 'author_email': 'xxx'})
108 dist
.script_name
= 'setup.py'
111 sys
.argv
= ['setup.py']
112 cmd
= bdist_rpm(dist
)
113 cmd
.fix_python
= True
116 cmd
.ensure_finalized()
119 dist_created
= os
.listdir(os
.path
.join(pkg_dir
, 'dist'))
120 self
.assertTrue('foo-0.1-1.noarch.rpm' in dist_created
)
121 os
.remove(os
.path
.join(pkg_dir
, 'dist', 'foo-0.1-1.noarch.rpm'))
124 return unittest
.makeSuite(BuildRpmTestCase
)
126 if __name__
== '__main__':
127 run_unittest(test_suite())