How to use the covimerage.coveragepy.FileReporter function in covimerage

To help you get started, we’ve selected a few covimerage 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 Vimjas / covimerage / tests / test_coveragepy.py View on Github external
def test_filereporter_source_handles_latin1(tmpdir):
    from covimerage.coveragepy import FileReporter

    with tmpdir.as_cwd():
        with open('iso.txt', 'wb') as f:
            f.write(b'Hellstr\xf6m')
        with open('utf8.txt', 'wb') as f:
            f.write(b'Hellstr\xc3\xb6m')

        assert FileReporter('iso.txt').source().encode(
            'utf-8') == b'Hellstr\xc3\xb6m'
        assert FileReporter('iso.txt').source().encode(
            'utf-8') == b'Hellstr\xc3\xb6m'
github Vimjas / covimerage / tests / test_coveragepy.py View on Github external
def test_filereporter():
    from covimerage.coveragepy import FileReporter

    f = FileReporter('/doesnotexist')
    assert repr(f) == ""

    with pytest.raises(coverage.misc.NoSource) as excinfo:
        f.lines()
    assert excinfo.value.args == (
        "[Errno 2] No such file or directory: '/doesnotexist'",)
github Vimjas / covimerage / tests / test_coveragepy.py View on Github external
def test_filereporter_source_exception(mocker, devnull):
    from covimerage.coveragepy import CoverageWrapperException, FileReporter

    class CustomException(Exception):
        pass

    m = mocker.mock_open()
    m.return_value.read.side_effect = CustomException
    mocker.patch('covimerage.coveragepy.open', m)

    f = FileReporter(devnull.name)
    with pytest.raises(CoverageWrapperException) as excinfo:
        f.source()

    assert isinstance(excinfo.value.orig_exc, CustomException)
github Vimjas / covimerage / covimerage / coveragepy.py View on Github external
def file_reporter(self, filename):
        return FileReporter(filename)
github Vimjas / covimerage / covimerage / coveragepy.py View on Github external
def _get_file_reporter(self, morf):
                return FileReporter(morf)