From d093671fc806898a6c194767b4f33a50f7681ab5 Mon Sep 17 00:00:00 2001 From: Tristan Van Berkom Date: Tue, 5 Mar 2019 12:47:02 +0900 Subject: tests/testutils/artifactshare.py: Support optional coverage This scaffolding needs to manually tell coverage to cleanup when sigterm happens in the process in order to collect the coverage report, but we need to do this conditionally in case we are running tests without coverage support. --- tests/testutils/artifactshare.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/testutils/artifactshare.py b/tests/testutils/artifactshare.py index 85fdcf30b..1e417c592 100644 --- a/tests/testutils/artifactshare.py +++ b/tests/testutils/artifactshare.py @@ -8,7 +8,6 @@ from collections import namedtuple from contextlib import contextmanager from multiprocessing import Process, Queue -import pytest_cov from buildstream import _yaml from buildstream._artifactcache.cascache import CASCache @@ -75,7 +74,13 @@ class ArtifactShare(): # Run the artifact server. # def run(self, q): - pytest_cov.embed.cleanup_on_sigterm() + + try: + import pytest_cov + except ImportError: + pass + else: + pytest_cov.embed.cleanup_on_sigterm() # Optionally mock statvfs if self.total_space: -- cgit v1.2.1