Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
cov = CoverageWrapper(data_file=coverage_fileobj)
assert cov._cov_obj.config.report_include is None
assert cov.lines == {vim_src: [3, 8, 9, 11, 13, 14, 15, 17, 23]}
cov.report()
out, err = capfd.readouterr()
assert 'test_plugin/conditional_function.vim' in out
assert err == ''
coveragerc = str(tmpdir.join('.coveragerc'))
with open(coveragerc, 'w') as f:
f.write('[report]\ninclude = foo/*,bar/*')
coverage_fileobj.seek(0)
cov = CoverageWrapper(data_file=coverage_fileobj)
assert cov._cov_obj.config.report_include == ['foo/*', 'bar/*']
with pytest.raises(CoverageWrapperException) as excinfo:
cov.report()
assert excinfo.value.args == ('No data to report. (CoverageException)',)
out, err = capfd.readouterr()
assert out.splitlines() == [
'Name Stmts Miss Cover',
'---------------------------']
assert err == ''
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)
def test_coveragewrapperexception():
from covimerage.coveragepy import CoverageWrapperException
assert CoverageWrapperException('foo').format_message() == 'foo'
with pytest.raises(CoverageWrapperException) as excinfo:
try:
raise Exception('orig')
except Exception as orig_exc:
raise CoverageWrapperException('bar', orig_exc=orig_exc)
assert excinfo.value.format_message() == "bar (Exception: orig)"
def test_coveragewrapperexception():
from covimerage.coveragepy import CoverageWrapperException
assert CoverageWrapperException('foo').format_message() == 'foo'
with pytest.raises(CoverageWrapperException) as excinfo:
try:
raise Exception('orig')
except Exception as orig_exc:
raise CoverageWrapperException('bar', orig_exc=orig_exc)
assert excinfo.value.format_message() == "bar (Exception: orig)"