Skip to content

Commit d9ba05d

Browse files
author
sprenger
committed
[utils] catch warnings in test_misc
1 parent 358e16f commit d9ba05d

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

neo/test/utils/test_misc.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"""
44

55
import unittest
6+
import warnings
67

78
import numpy as np
89
import quantities as pq
@@ -374,7 +375,10 @@ def test__cut_block_by_epochs(self):
374375
original_block.segments = [seg, seg2]
375376
original_block.create_many_to_one_relationship()
376377

377-
block = cut_block_by_epochs(original_block, properties={'pick': 'me'})
378+
with warnings.catch_warnings(record=True) as w:
379+
# This should raise a warning as one segment does not contain epochs
380+
block = cut_block_by_epochs(original_block, properties={'pick': 'me'})
381+
self.assertEqual(len(w), 1)
378382

379383
assert_neo_object_is_compliant(block)
380384
self.assertEqual(len(block.segments), 3)
@@ -430,7 +434,10 @@ def test__cut_block_by_epochs(self):
430434
original_block.segments = [seg, seg2]
431435
original_block.create_many_to_one_relationship()
432436

433-
block = cut_block_by_epochs(original_block, properties={'pick': 'me'}, reset_time=True)
437+
with warnings.catch_warnings(record=True) as w:
438+
# This should raise a warning as one segment does not contain epochs
439+
block = cut_block_by_epochs(original_block, properties={'pick': 'me'}, reset_time=True)
440+
self.assertEqual(len(w), 1)
434441

435442
assert_neo_object_is_compliant(block)
436443
self.assertEqual(len(block.segments), 3)

0 commit comments

Comments
 (0)