def test_coverage(venv): venv_with_coverage = virtual_environments.prepare_virtualenv(venv.packages + ["coverage==3.7.1"]) coverage_file = os.path.join(virtual_environments.get_vroot(), "coverage-temp.xml") output = run(venv_with_coverage, 'coverage', options="--with-coverage --cover-erase --cover-tests --cover-xml --cover-xml-file=\"" + coverage_file + "\"") assert_service_messages( output, [ ServiceMessage('testStarted', {'name': 'testa.test_mycode'}), ServiceMessage('testFinished', {'name': 'testa.test_mycode'}), ]) f = open(coverage_file, "rb") content = str(f.read()) f.close() assert content.find('<line hits="1" number="2"/>') > 0