CoolFace
Apppublic

Aluode/PerceptionLabPortable

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes
test_bdist_dumb.py79 linesDownload Raw Back to tests
1"""Tests for distutils.command.bdist_dumb."""2 3import os4import sys5import zipfile6from distutils.command.bdist_dumb import bdist_dumb7from distutils.core import Distribution8from distutils.tests import support9 10import pytest11 12SETUP_PY = """\13from distutils.core import setup14import foo15 16setup(name='foo', version='0.1', py_modules=['foo'],17      url='xxx', author='xxx', author_email='xxx')18 19"""20 21 22@support.combine_markers23@pytest.mark.usefixtures('save_env')24@pytest.mark.usefixtures('save_argv')25@pytest.mark.usefixtures('save_cwd')26class TestBuildDumb(27    support.TempdirManager,28):29    @pytest.mark.usefixtures('needs_zlib')30    def test_simple_built(self):31        # let's create a simple package32        tmp_dir = self.mkdtemp()33        pkg_dir = os.path.join(tmp_dir, 'foo')34        os.mkdir(pkg_dir)35        self.write_file((pkg_dir, 'setup.py'), SETUP_PY)36        self.write_file((pkg_dir, 'foo.py'), '#')37        self.write_file((pkg_dir, 'MANIFEST.in'), 'include foo.py')38        self.write_file((pkg_dir, 'README'), '')39 40        dist = Distribution({41            'name': 'foo',42            'version': '0.1',43            'py_modules': ['foo'],44            'url': 'xxx',45            'author': 'xxx',46            'author_email': 'xxx',47        })48        dist.script_name = 'setup.py'49        os.chdir(pkg_dir)50 51        sys.argv = ['setup.py']52        cmd = bdist_dumb(dist)53 54        # so the output is the same no matter55        # what is the platform56        cmd.format = 'zip'57 58        cmd.ensure_finalized()59        cmd.run()60 61        # see what we have62        dist_created = os.listdir(os.path.join(pkg_dir, 'dist'))63        base = f"{dist.get_fullname()}.{cmd.plat_name}.zip"64 65        assert dist_created == [base]66 67        # now let's check what we have in the zip file68        fp = zipfile.ZipFile(os.path.join('dist', base))69        try:70            contents = fp.namelist()71        finally:72            fp.close()73 74        contents = sorted(filter(None, map(os.path.basename, contents)))75        wanted = ['foo-0.1-py{}.{}.egg-info'.format(*sys.version_info[:2]), 'foo.py']76        if not sys.dont_write_bytecode:77            wanted.append(f'foo.{sys.implementation.cache_tag}.pyc')78        assert contents == sorted(wanted)79