def test_sanity_check_wheel(self): # Sanity check that the setUpClass() created the wheel, that it can be # pip installed in a temporary directory, and that with only the # installed package on sys.path, the package can be imported and run. dist_dir = temporary_directory() self.addCleanup(dist_dir.cleanup) with chdir(self.example_dir): call([ sys.executable, 'setup.py', '--no-user-cfg', 'bdist_wheel', '--universal', '--dist-dir', dist_dir.name, ]) wheels = glob(os.path.join(dist_dir.name, '*.whl')) self.assertEqual(len(wheels), 1) wheel = wheels[0] with temporary_directory() as tempdir: call(['pip', 'install', '--target', tempdir, wheel]) result = output( [sys.executable, '-c', 'import stupid; stupid.yes()'], env=dict(PYTHONPATH=tempdir)) self.assertEqual(result, 'yes\n')
def call(self, command, **kws): assert self.id is not None, 'No schroot session' if isinstance(command, str): command = command.split() session_cmd = ['schroot', '-u', 'root', '-rc', self.id, '--'] if 'env' in kws: session_cmd.insert(-1, '--preserve-environment') session_cmd.extend(command) call(session_cmd, **kws)
def _install_example(self): with chdir(self.example_dir): call([ self.python, 'setup.py', '--no-user-cfg', '--command-packages=stdeb.command', 'bdist_deb' ]) # bdist_deb can't be told where to leave its artifacts, so # make sure that cruft gets cleaned up after this test. dist_dir = os.path.join(self.example_dir, 'deb_dist') self.addCleanup(shutil.rmtree, os.path.join(dist_dir)) tar_gzs = glob(os.path.join(self.example_dir, '*.tar.gz')) if len(tar_gzs) > 0: assert len(tar_gzs) == 1, tar_gzs self.addCleanup(os.remove, tar_gzs[0]) # Install the .deb and all its dependencies in the schroot. debs = glob(os.path.join(dist_dir, '*.deb')) self.assertEqual(len(debs), 1) deb = debs[0] self.session.call(['gdebi', '-n', deb])
def end(self): assert self.id is not None, 'No session' self.call('rm -rf dist') call(['schroot', '-u', 'root', '-c', self.id, '--end-session']) self.id = None