예제 #1
0
def test_compile_missing_pyc(testing_workdir):
    good_files = ['f1.py', 'f3.py']
    bad_file = 'f2_bad.py'
    tmp = os.path.join(testing_workdir, 'tmp')
    shutil.copytree(os.path.join(os.path.dirname(__file__), 'test-recipes',
                                 'metadata', '_compile-test'), tmp)
    post.compile_missing_pyc(os.listdir(tmp), cwd=tmp,
                                python_exe=sys.executable)
    for f in good_files:
        assert os.path.isfile(os.path.join(tmp, add_mangling(f)))
    assert not os.path.isfile(os.path.join(tmp, add_mangling(bad_file)))
예제 #2
0
def test_compile_missing_pyc(testing_workdir):
    good_files = ['f1.py', 'f3.py']
    bad_file = 'f2_bad.py'
    tmp = os.path.join(testing_workdir, 'tmp')
    shutil.copytree(os.path.join(os.path.dirname(__file__), 'test-recipes',
                                 'metadata', '_compile-test'), tmp)
    post.compile_missing_pyc(os.listdir(tmp), cwd=tmp,
                                python_exe=sys.executable)
    for f in good_files:
        assert os.path.isfile(os.path.join(tmp, add_mangling(f)))
    assert not os.path.isfile(os.path.join(tmp, add_mangling(bad_file)))
예제 #3
0
def test_compile_missing_pyc():
    cwd = os.getcwd()
    good_files = ['f1.py', 'f3.py']
    bad_file = 'f2_bad.py'
    with TemporaryDirectory() as tmp:
        tmpdir = os.path.join(tmp, 'files')
        shutil.copytree(os.path.join(os.path.dirname(__file__), 'test-recipes',
                                     'metadata', '_compile-test'),
                        tmpdir)
        os.chdir(tmpdir)
        try:
            post.compile_missing_pyc(os.listdir(tmpdir), cwd=tmpdir, python_exe=sys.executable)
            files = os.listdir(tmpdir)
            for f in good_files:
                assert f + 'c' in files
            assert bad_file + 'c' not in files
        except:
            raise
        finally:
            os.chdir(cwd)