Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
test_bdist_egg.py74 linesDownload Raw Back to tests
1"""develop tests"""2 3import os4import re5import zipfile6 7import pytest8 9from setuptools.dist import Distribution10 11from . import contexts12 13SETUP_PY = """\14from setuptools import setup15 16setup(py_modules=['hi'])17"""18 19 20@pytest.fixture21def setup_context(tmpdir):22    with (tmpdir / 'setup.py').open('w') as f:23        f.write(SETUP_PY)24    with (tmpdir / 'hi.py').open('w') as f:25        f.write('1\n')26    with tmpdir.as_cwd():27        yield tmpdir28 29 30class Test:31    @pytest.mark.usefixtures("user_override")32    @pytest.mark.usefixtures("setup_context")33    def test_bdist_egg(self):34        dist = Distribution(35            dict(36                script_name='setup.py',37                script_args=['bdist_egg'],38                name='foo',39                py_modules=['hi'],40            )41        )42        os.makedirs(os.path.join('build', 'src'))43        with contexts.quiet():44            dist.parse_command_line()45            dist.run_commands()46 47        # let's see if we got our egg link at the right place48        [content] = os.listdir('dist')49        assert re.match(r'foo-0.0.0-py[23].\d+.egg$', content)50 51    @pytest.mark.xfail(52        os.environ.get('PYTHONDONTWRITEBYTECODE', False),53        reason="Byte code disabled",54    )55    @pytest.mark.usefixtures("user_override")56    @pytest.mark.usefixtures("setup_context")57    def test_exclude_source_files(self):58        dist = Distribution(59            dict(60                script_name='setup.py',61                script_args=['bdist_egg', '--exclude-source-files'],62                py_modules=['hi'],63            )64        )65        with contexts.quiet():66            dist.parse_command_line()67            dist.run_commands()68        [dist_name] = os.listdir('dist')69        dist_filename = os.path.join('dist', dist_name)70        zip = zipfile.ZipFile(dist_filename)71        names = list(zi.filename for zi in zip.filelist)72        assert 'hi.pyc' in names73        assert 'hi.py' not in names74 
codekingpro/portable-devtools · Team Ai