How to use the pycobertura.filesystem.ZipFileSystem function in pycobertura

To help you get started, we’ve selected a few pycobertura examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aconrad / pycobertura / tests / test_filesystem.py View on Github external
def test_filesystem_zip__file_not_found():
    from pycobertura.filesystem import ZipFileSystem

    fs = ZipFileSystem("tests/dummy/dummy.zip")

    dummy_source_file = 'foo/non-existent-file.py'
    try:
        with fs.open(dummy_source_file) as f:
            pass
    except ZipFileSystem.FileNotFound as fnf:
        assert fnf.path == dummy_source_file
github aconrad / pycobertura / tests / test_filesystem.py View on Github external
def test_filesystem_zip__with_source_prefix():
    from pycobertura.filesystem import ZipFileSystem

    fs = ZipFileSystem(
        "tests/dummy/dummy-with-prefix.zip",  # code zipped as dummy-with-prefix/dummy/dummy.py
        source_prefix="dummy-with-prefix",
    )

    source_files_in_zip = [
        'dummy/dummy.py',
        'dummy/dummy2.py',
    ]

    for source_file in source_files_in_zip:
        with fs.open(source_file) as f:
            assert hasattr(f, 'read')
github aconrad / pycobertura / tests / test_filesystem.py View on Github external
def test_filesystem_zip__returns_fileobject():
    from pycobertura.filesystem import ZipFileSystem

    fs = ZipFileSystem("tests/dummy/dummy.zip")

    source_files_in_zip = [
        'dummy/dummy.py',
        'dummy/dummy2.py',
    ]

    for source_file in source_files_in_zip:
        with fs.open(source_file) as f:
            assert hasattr(f, 'read')
github aconrad / pycobertura / tests / test_filesystem.py View on Github external
def test_filesystem_zip__file_not_found():
    from pycobertura.filesystem import ZipFileSystem

    fs = ZipFileSystem("tests/dummy/dummy.zip")

    dummy_source_file = 'foo/non-existent-file.py'
    try:
        with fs.open(dummy_source_file) as f:
            pass
    except ZipFileSystem.FileNotFound as fnf:
        assert fnf.path == dummy_source_file
github aconrad / pycobertura / pycobertura / filesystem.py View on Github external
The optional argument `source_prefix` will be used to lookup source
    files if a zip archive is provided and will be prepended to filenames
    found in the coverage report.

    The optional argument `ref` will be taken into account when
    instantiating a GitFileSystem, and it shall be a branch name, a commit
    ID or a git ref ID.
    """
    if source is None:
        if isinstance(report, str):
            # get the directory in which the coverage file lives
            source = os.path.dirname(report)

    if zipfile.is_zipfile(source):
        return ZipFileSystem(source, source_prefix=source_prefix)

    if ref:
        return GitFileSystem(source, ref)

    return DirectoryFileSystem(source, source_prefix=source_prefix)