Exemplo n.º 1
0
def test_compressed_listing(tmpdir):
    def in_tmpdir(paths):
        li = []
        for path in paths:
            li.append(
                str(
                    os.path.normcase(
                        os.path.join(tmpdir, path.replace("/", os.path.sep)))))
        return li

    sample = in_tmpdir([
        "lib/mypkg.dist-info/METADATA",
        "lib/mypkg.dist-info/PKG-INFO",
        "lib/mypkg/would_be_removed.txt",
        "lib/mypkg/would_be_skipped.skip.txt",
        "lib/mypkg/__init__.py",
        "lib/mypkg/my_awesome_code.py",
        "lib/mypkg/__pycache__/my_awesome_code-magic.pyc",
        "lib/mypkg/support/support_file.py",
        "lib/mypkg/support/more_support.py",
        "lib/mypkg/support/would_be_skipped.skip.py",
        "lib/mypkg/support/__pycache__/support_file-magic.pyc",
        "lib/random_other_place/file_without_a_dot_pyc",
        "bin/mybin",
    ])

    # Create the required files
    for fname in sample:
        create_file(fname, "random blub")

    # Remove the files to be skipped from the paths
    sample = [path for path in sample if ".skip." not in path]

    expected_remove = in_tmpdir([
        "bin/mybin",
        "lib/mypkg.dist-info/*",
        "lib/mypkg/*",
        "lib/random_other_place/file_without_a_dot_pyc",
    ])

    expected_skip = in_tmpdir([
        "lib/mypkg/would_be_skipped.skip.txt",
        "lib/mypkg/support/would_be_skipped.skip.py",
    ])

    will_remove, will_skip = compress_for_output_listing(sample)
    assert sorted(expected_skip) == sorted(compact(will_skip))
    assert sorted(expected_remove) == sorted(compact(will_remove))
Exemplo n.º 2
0
def test_compressed_listing(tmpdir):
    def in_tmpdir(paths):
        li = []
        for path in paths:
            li.append(
                str(os.path.join(tmpdir, path.replace("/", os.path.sep)))
            )
        return li

    sample = in_tmpdir([
        "lib/mypkg.dist-info/METADATA",
        "lib/mypkg.dist-info/PKG-INFO",
        "lib/mypkg/would_be_removed.txt",
        "lib/mypkg/would_be_skipped.skip.txt",
        "lib/mypkg/__init__.py",
        "lib/mypkg/my_awesome_code.py",
        "lib/mypkg/__pycache__/my_awesome_code-magic.pyc",
        "lib/mypkg/support/support_file.py",
        "lib/mypkg/support/more_support.py",
        "lib/mypkg/support/would_be_skipped.skip.py",
        "lib/mypkg/support/__pycache__/support_file-magic.pyc",
        "lib/random_other_place/file_without_a_dot_pyc",
        "bin/mybin",
    ])

    # Create the required files
    for fname in sample:
        create_file(fname, "random blub")

    # Remove the files to be skipped from the paths
    sample = [path for path in sample if ".skip." not in path]

    expected_remove = in_tmpdir([
        "bin/mybin",
        "lib/mypkg.dist-info/*",
        "lib/mypkg/*",
        "lib/random_other_place/file_without_a_dot_pyc",
    ])

    expected_skip = in_tmpdir([
        "lib/mypkg/would_be_skipped.skip.txt",
        "lib/mypkg/support/would_be_skipped.skip.py",
    ])

    will_remove, will_skip = compress_for_output_listing(sample)
    assert sorted(expected_skip) == sorted(compact(will_skip))
    assert sorted(expected_remove) == sorted(compact(will_remove))