本文整理汇总了Python中obspy.core.AttribDict.test方法的典型用法代码示例。如果您正苦于以下问题:Python AttribDict.test方法的具体用法?Python AttribDict.test怎么用?Python AttribDict.test使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类obspy.core.AttribDict
的用法示例。
在下文中一共展示了AttribDict.test方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_setattr
# 需要导入模块: from obspy.core import AttribDict [as 别名]
# 或者: from obspy.core.AttribDict import test [as 别名]
def test_setattr(self):
"""
Tests __setattr__ method of AttribDict class.
"""
# 1
ad = AttribDict()
ad.test = 'NEW'
self.assertEqual(ad['test'], 'NEW')
self.assertEqual(ad.test, 'NEW')
self.assertEqual(ad.get('test'), 'NEW')
self.assertEqual(ad.__getattr__('test'), 'NEW')
self.assertEqual(ad.__getitem__('test'), 'NEW')
self.assertEqual(ad.__dict__['test'], 'NEW')
self.assertEqual(ad.__dict__.get('test'), 'NEW')
self.assertIn('test', ad)
self.assertIn('test', ad.__dict__)
# 2
ad = AttribDict()
ad.__setattr__('test', 'NEW')
self.assertEqual(ad['test'], 'NEW')
self.assertEqual(ad.test, 'NEW')
self.assertEqual(ad.get('test'), 'NEW')
self.assertEqual(ad.__getattr__('test'), 'NEW')
self.assertEqual(ad.__getitem__('test'), 'NEW')
self.assertEqual(ad.__dict__['test'], 'NEW')
self.assertEqual(ad.__dict__.get('test'), 'NEW')
self.assertIn('test', ad)
self.assertIn('test', ad.__dict__)
示例2: test_setattr
# 需要导入模块: from obspy.core import AttribDict [as 别名]
# 或者: from obspy.core.AttribDict import test [as 别名]
def test_setattr(self):
"""
Tests __setattr__ method of AttribDict class.
"""
# 1
ad = AttribDict()
ad.test = "NEW"
self.assertEqual(ad["test"], "NEW")
self.assertEqual(ad.test, "NEW")
self.assertEqual(ad.get("test"), "NEW")
self.assertEqual(ad.__getattr__("test"), "NEW")
self.assertEqual(ad.__getitem__("test"), "NEW")
self.assertEqual(ad.__dict__["test"], "NEW")
self.assertEqual(ad.__dict__.get("test"), "NEW")
self.assertTrue("test" in ad)
self.assertTrue("test" in ad.__dict__)
# 2
ad = AttribDict()
ad.__setattr__("test", "NEW")
self.assertEqual(ad["test"], "NEW")
self.assertEqual(ad.test, "NEW")
self.assertEqual(ad.get("test"), "NEW")
self.assertEqual(ad.__getattr__("test"), "NEW")
self.assertEqual(ad.__getitem__("test"), "NEW")
self.assertEqual(ad.__dict__["test"], "NEW")
self.assertEqual(ad.__dict__.get("test"), "NEW")
self.assertTrue("test" in ad)
self.assertTrue("test" in ad.__dict__)
示例3: test_clear
# 需要导入模块: from obspy.core import AttribDict [as 别名]
# 或者: from obspy.core.AttribDict import test [as 别名]
def test_clear(self):
"""
Tests clear method of AttribDict class.
"""
ad = AttribDict()
ad.test = 1
ad['test2'] = 'test'
# removing via pop
ad.clear()
self.assertFalse('test' in ad)
self.assertFalse('test2' in ad)
self.assertFalse('test' in ad.__dict__)
self.assertFalse('test2' in ad.__dict__)
self.assertFalse(hasattr(ad, 'test'))
self.assertFalse(hasattr(ad, 'test2'))
# class attributes should be still present
self.assertTrue(hasattr(ad, 'readonly'))
self.assertTrue(hasattr(ad, 'defaults'))
示例4: test_pop
# 需要导入模块: from obspy.core import AttribDict [as 别名]
# 或者: from obspy.core.AttribDict import test [as 别名]
def test_pop(self):
"""
Tests pop method of AttribDict class.
"""
ad = AttribDict()
ad.test = 1
ad['test2'] = 'test'
# removing via pop
temp = ad.pop('test')
self.assertEqual(temp, 1)
self.assertFalse('test' in ad)
self.assertIn('test2', ad)
self.assertFalse('test' in ad.__dict__)
self.assertIn('test2', ad.__dict__)
self.assertFalse(hasattr(ad, 'test'))
self.assertTrue(hasattr(ad, 'test2'))
# using pop() for not existing element raises a KeyError
self.assertRaises(KeyError, ad.pop, 'test')
示例5: test_pop
# 需要导入模块: from obspy.core import AttribDict [as 别名]
# 或者: from obspy.core.AttribDict import test [as 别名]
def test_pop(self):
"""
Tests pop method of AttribDict class.
"""
ad = AttribDict()
ad.test = 1
ad["test2"] = "test"
# removing via pop
temp = ad.pop("test")
self.assertEquals(temp, 1)
self.assertFalse("test" in ad)
self.assertTrue("test2" in ad)
self.assertFalse("test" in ad.__dict__)
self.assertTrue("test2" in ad.__dict__)
self.assertFalse(hasattr(ad, "test"))
self.assertTrue(hasattr(ad, "test2"))
# using pop() for not existing element raises a KeyError
self.assertRaises(KeyError, ad.pop, "test")
示例6: test_delete
# 需要导入模块: from obspy.core import AttribDict [as 别名]
# 或者: from obspy.core.AttribDict import test [as 别名]
def test_delete(self):
"""
Tests delete method of AttribDict class.
"""
ad = AttribDict()
ad.test = 1
ad['test2'] = 'test'
# deleting test using dictionary
del ad['test']
self.assertFalse('test' in ad)
self.assertIn('test2', ad)
self.assertFalse('test' in ad.__dict__)
self.assertIn('test2', ad.__dict__)
self.assertFalse(hasattr(ad, 'test'))
self.assertTrue(hasattr(ad, 'test2'))
# deleting test2 using attribute
del ad.test2
self.assertFalse('test2' in ad)
self.assertFalse('test2' in ad.__dict__)
self.assertFalse(hasattr(ad, 'test2'))
示例7: test_delete
# 需要导入模块: from obspy.core import AttribDict [as 别名]
# 或者: from obspy.core.AttribDict import test [as 别名]
def test_delete(self):
"""
Tests delete method of AttribDict class.
"""
ad = AttribDict()
ad.test = 1
ad["test2"] = "test"
# deleting test using dictionary
del ad["test"]
self.assertFalse("test" in ad)
self.assertTrue("test2" in ad)
self.assertFalse("test" in ad.__dict__)
self.assertTrue("test2" in ad.__dict__)
self.assertFalse(hasattr(ad, "test"))
self.assertTrue(hasattr(ad, "test2"))
# deleting test2 using attribute
del ad.test2
self.assertFalse("test2" in ad)
self.assertFalse("test2" in ad.__dict__)
self.assertFalse(hasattr(ad, "test2"))