当前位置: 首页>>代码示例>>Python>>正文


Python AttribDict.test方法代码示例

本文整理汇总了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__)
开发者ID:3rdcycle,项目名称:obspy,代码行数:30,代码来源:test_util_attribdict.py

示例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__)
开发者ID:gauteh,项目名称:obspy,代码行数:30,代码来源:test_util_attribdict.py

示例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'))
开发者ID:3rdcycle,项目名称:obspy,代码行数:20,代码来源:test_util_attribdict.py

示例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')
开发者ID:3rdcycle,项目名称:obspy,代码行数:20,代码来源:test_util_attribdict.py

示例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")
开发者ID:gauteh,项目名称:obspy,代码行数:20,代码来源:test_util_attribdict.py

示例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'))
开发者ID:3rdcycle,项目名称:obspy,代码行数:22,代码来源:test_util_attribdict.py

示例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"))
开发者ID:gauteh,项目名称:obspy,代码行数:22,代码来源:test_util_attribdict.py


注:本文中的obspy.core.AttribDict.test方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。