本文整理汇总了Python中obspy.core.event.Pick.test_2方法的典型用法代码示例。如果您正苦于以下问题:Python Pick.test_2方法的具体用法?Python Pick.test_2怎么用?Python Pick.test_2使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类obspy.core.event.Pick
的用法示例。
在下文中一共展示了Pick.test_2方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_clear_method_resets_objects
# 需要导入模块: from obspy.core.event import Pick [as 别名]
# 或者: from obspy.core.event.Pick import test_2 [as 别名]
def test_clear_method_resets_objects(self):
"""
Tests that the clear() method properly resets all objects. Test for
#449.
"""
# Test with basic event object.
e = Event(force_resource_id=False)
e.comments.append(Comment(text="test"))
e.event_type = "explosion"
self.assertEqual(len(e.comments), 1)
self.assertEqual(e.event_type, "explosion")
e.clear()
self.assertEqual(e, Event(force_resource_id=False))
self.assertEqual(len(e.comments), 0)
self.assertEqual(e.event_type, None)
# Test with pick object. Does not really fit in the event test case but
# it tests the same thing...
p = Pick()
p.comments.append(Comment(text="test"))
p.phase_hint = "p"
self.assertEqual(len(p.comments), 1)
self.assertEqual(p.phase_hint, "p")
# Add some more random attributes. These should disappear upon
# cleaning.
p.test_1 = "a"
p.test_2 = "b"
self.assertEqual(p.test_1, "a")
self.assertEqual(p.test_2, "b")
p.clear()
self.assertEqual(len(p.comments), 0)
self.assertEqual(p.phase_hint, None)
self.assertFalse(hasattr(p, "test_1"))
self.assertFalse(hasattr(p, "test_2"))
示例2: test_clear_method_resets_objects
# 需要导入模块: from obspy.core.event import Pick [as 别名]
# 或者: from obspy.core.event.Pick import test_2 [as 别名]
def test_clear_method_resets_objects(self):
"""
Tests that the clear() method properly resets all objects. Test for
#449.
"""
# Test with basic event object.
e = Event(force_resource_id=False)
e.comments.append(Comment(text="test"))
e.event_type = "explosion"
self.assertEqual(len(e.comments), 1)
self.assertEqual(e.event_type, "explosion")
e.clear()
self.assertEqual(e, Event(force_resource_id=False))
self.assertEqual(len(e.comments), 0)
self.assertEqual(e.event_type, None)
# Test with pick object. Does not really fit in the event test case but
# it tests the same thing...
p = Pick()
p.comments.append(Comment(text="test"))
p.phase_hint = "p"
self.assertEqual(len(p.comments), 1)
self.assertEqual(p.phase_hint, "p")
# Add some more random attributes. These should disappear upon
# cleaning.
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")
p.test_1 = "a"
p.test_2 = "b"
# two warnings should have been issued by setting non-default keys
self.assertEqual(len(w), 2)
self.assertEqual(p.test_1, "a")
self.assertEqual(p.test_2, "b")
p.clear()
self.assertEqual(len(p.comments), 0)
self.assertEqual(p.phase_hint, None)
self.assertFalse(hasattr(p, "test_1"))
self.assertFalse(hasattr(p, "test_2"))