Skip to content

Commit

Permalink
Cope with Process coverage reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
calum-chamberlain committed Dec 8, 2023
1 parent 0e2e5da commit f5e81a5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[run]
branch = True
source = eqcorrscan
concurrency = multiprocessing
omit =
eqcorrscan/__init__.py
eqcorrscan/*/__init__.py
Expand Down
16 changes: 15 additions & 1 deletion eqcorrscan/tests/matched_filter/helper_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@
_get_detection_stream, Poison, _prepper, _pre_processor,
_make_detections)

try:
from pytest_cov.embed import cleanup_on_sigterm
except ImportError:
pass
else:
cleanup_on_sigterm()


Logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -113,7 +120,7 @@ def setUpClass(cls):
templates=templates,
group_size=5,
groups=None,
xcorr_func="fftw",
xcorr_func="fmf",
)

def setUp(self):
Expand Down Expand Up @@ -277,6 +284,7 @@ def test_normal_operation(self):
# Wait for the process to end
time.sleep(self.wait_time)
self.assertFalse(self.process.is_alive())
self.process.join()

def test_full_stream_operation(self):
kwargs = copy.copy(self.kwargs)
Expand Down Expand Up @@ -313,6 +321,7 @@ def test_full_stream_operation(self):

# Cleanup
self.directories_to_nuke.append(kwargs['full_stream_dir'])
process.join()

def test_exception_handling(self):
kwargs = copy.copy(self.kwargs)
Expand All @@ -335,6 +344,7 @@ def test_exception_handling(self):
self.assertIsInstance(poison, Poison)
time.sleep(self.wait_time)
self.assertFalse(process.is_alive())
process.join()


###############################################################################
Expand All @@ -348,6 +358,7 @@ def poisoning(obj: ProcessTests):
obj.kwargs['poison_queue'].put(Exception("TestException"))
time.sleep(obj.wait_time)
obj.assertFalse(obj.process.is_alive())
obj.process.join()


def poisoning_while_waiting_on_output(obj: ProcessTests):
Expand All @@ -356,13 +367,16 @@ def poisoning_while_waiting_on_output(obj: ProcessTests):
obj.kwargs['poison_queue'].put(Exception("TestException"))
time.sleep(obj.wait_time)
obj.assertFalse(obj.process.is_alive())
obj.process.join()


def poisoning_from_input(obj: ProcessTests, input_queue: Queue):
obj.process.start()
# Test death
input_queue.put(Poison(Exception("TestException")))
time.sleep(obj.wait_time)
obj.assertFalse(obj.process.is_alive())
obj.process.join()


if __name__ == '__main__':
Expand Down

0 comments on commit f5e81a5

Please sign in to comment.