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


Python utils.ServiceOptsDict类代码示例

本文整理汇总了Python中omero.gateway.utils.ServiceOptsDict的典型用法代码示例。如果您正苦于以下问题:Python ServiceOptsDict类的具体用法?Python ServiceOptsDict怎么用?Python ServiceOptsDict使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ServiceOptsDict类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_clear

    def test_clear(self):
        d = ServiceOptsDict(
            {"omero.group": -1, "omero.user": 1, "omero.share": 2})
        d.clear()
        assert d == {}

        pytest.raises(TypeError, d.clear, None)
开发者ID:kennethgillen,项目名称:openmicroscopy,代码行数:7,代码来源:test_utils.py

示例2: test_keys

    def test_keys(self):
        d = ServiceOptsDict()
        assert d.keys() == []

        d = ServiceOptsDict({"omero.group": -1})
        assert 'omero.group' in d

        pytest.raises(TypeError, d.keys, None)
开发者ID:kennethgillen,项目名称:openmicroscopy,代码行数:8,代码来源:test_utils.py

示例3: test_items

    def test_items(self):
        d = ServiceOptsDict()
        assert d.items() ==  []

        d = ServiceOptsDict({"omero.group":-1})
        assert d.items() ==  [("omero.group", "-1")]

        pytest.raises(TypeError, d.items, None)
开发者ID:bramalingam,项目名称:openmicroscopy,代码行数:8,代码来源:test_utils.py

示例4: test_has_key

    def test_has_key(self):
        d = ServiceOptsDict()
        assert "omero" not in d

        d = ServiceOptsDict({"omero.group": -1, "omero.user": 1})
        k = d.keys()
        k.sort()
        assert k == ["omero.group", "omero.user"]

        pytest.raises(TypeError, d.has_key)
开发者ID:sbesson,项目名称:openmicroscopy,代码行数:10,代码来源:test_utils.py

示例5: test_has_key

 def test_has_key(self):
     d = ServiceOptsDict()
     assert not d.has_key('omero')
     
     d = ServiceOptsDict({"omero.group":-1, "omero.user": 1})
     k = d.keys()
     k.sort()
     assert k ==  ['omero.group', 'omero.user']
     
     pytest.raises(TypeError, d.has_key)
开发者ID:bramalingam,项目名称:openmicroscopy,代码行数:10,代码来源:test_utils.py

示例6: test_copy

    def test_copy(self):
        def getHash(obj):
            return hex(id(obj))

        d = ServiceOptsDict({"omero.group": -1, "omero.user": 1, "omero.share": 2})
        assert d.copy() == d
        assert getHash(d.copy()) != getHash(d)
        assert ServiceOptsDict().copy() == ServiceOptsDict()
        assert getHash(ServiceOptsDict().copy()) != getHash(ServiceOptsDict())
        pytest.raises(TypeError, d.copy, None)
开发者ID:sbesson,项目名称:openmicroscopy,代码行数:10,代码来源:test_utils.py

示例7: test_getitem

 def test_getitem(self):
     d = ServiceOptsDict({"omero.group":-1, "omero.user": 1})
     assert d["omero.group"] ==  "-1"
     assert d["omero.user"] ==  "1"
     
     d["omero.share"] = 2
     d["foo"] = "bar"
     assert d["omero.share"] ==  "2"
     assert d["foo"] ==  "bar"
     
     del d["omero.user"]
     
     assert d ==  {"omero.group": "-1", 'foo': 'bar', "omero.share": "2"}
     
     pytest.raises(TypeError, d.__getitem__)
     
     assert d.get("omero.user") ==  None
     assert d.get("omero.user", "5"), "5"
开发者ID:bramalingam,项目名称:openmicroscopy,代码行数:18,代码来源:test_utils.py

示例8: test_constructor

    def test_constructor(self):
        assert ServiceOptsDict() ==  {}
        assert ServiceOptsDict() is not {}
        assert ServiceOptsDict() is not dict()
        
        d = {"omero.group":-1}
        d = ServiceOptsDict(d)
        
        resd = d.get("omero.group")
        assert isinstance(resd, str)
        assert d.get("omero.group") ==  str(d["omero.group"])
        
        d = ServiceOptsDict(x=1,y=2)
        assert d.get("x") ==  "1"
        assert d.get("y") ==  "2"

        # ServiceOptsDict can be passed initializing data, but it needs to be a dict
        pytest.raises(AttributeError, ServiceOptsDict, kwargs={"data":"data"})
        s = ServiceOptsDict(data={'option':'a'})
开发者ID:bramalingam,项目名称:openmicroscopy,代码行数:19,代码来源:test_utils.py

示例9: test_constructor

    def test_constructor(self):
        self.assertEqual(ServiceOptsDict(), {})
        self.assert_(ServiceOptsDict() is not {})
        self.assert_(ServiceOptsDict() is not dict())
        
        d = {"omero.group":-1}
        d = ServiceOptsDict(d)
        
        resd = d.get("omero.group")
        self.assert_(isinstance(resd, str))
        self.assertEqual(d.get("omero.group"), str(d["omero.group"]))
        
        d = ServiceOptsDict(x=1,y=2)
        self.assertEqual(d.get("x"), "1")
        self.assertEqual(d.get("y"), "2")

        # ServiceOptsDict can be passed initializing data, but it needs to be a dict
        self.assertRaises(AttributeError, ServiceOptsDict, kwargs={"data":"data"})
        s = ServiceOptsDict(data={'option':'a'})
开发者ID:DirkHaehnel,项目名称:openmicroscopy,代码行数:19,代码来源:utils.py

示例10: test_values

 def test_values(self):
     d = ServiceOptsDict()
     assert d.values() ==  []
     
     d = ServiceOptsDict({"omero.group":-1})
     assert d.values() ==  ["-1"]
     
     pytest.raises(TypeError, d.values, None)
     
     d = ServiceOptsDict({"a":None, "b":True, "c":"foo", "d":1, "e":1.45, "f":[], "g":{}})
     assert d.values() ==  ['foo', '1.45', '1']
开发者ID:bramalingam,项目名称:openmicroscopy,代码行数:11,代码来源:test_utils.py

示例11: test_setter_an_getter

 def test_setter_an_getter(self):
     group = -1
     user = 1
     share = 2
     
     d = ServiceOptsDict()
     d.set("omero.group", group)
     assert d.get("omero.group") ==  d.getOmeroGroup()
     
     d.setOmeroGroup(group)
     assert d.get("omero.group") ==  d.getOmeroGroup()
     
     d.set("omero.user", user)
     assert d.get("omero.user") ==  d.getOmeroUser()
     
     d.setOmeroUser(user)
     assert d.get("omero.user") ==  d.getOmeroUser()
     
     d.set("omero.share", share)
     assert d.get("omero.share") ==  d.getOmeroShare()
     
     d.setOmeroShare(share)
     assert d.get("omero.share") ==  d.getOmeroShare()
开发者ID:bramalingam,项目名称:openmicroscopy,代码行数:23,代码来源:test_utils.py

示例12: test_setitem

    def test_setitem(self):
        
        # string
        d = ServiceOptsDict({"omero.share": "2","omero.user": "1"})
        d["omero.group"] = "-1"
        
        # unicode
        d = ServiceOptsDict({"omero.share": u'2',"omero.user": u'1'})
        d["omero.group"] = u'-1'
        
        # int
        d = ServiceOptsDict({"omero.share": 1,"omero.user": 2})
        d["omero.group"] = -1
        
        # long
        import sys
        maxint = sys.maxint
        d = ServiceOptsDict({"omero.group": (maxint+1)})
        d["omero.user"] = (maxint+1)

        # Setter passed None as value remove from internal dict
        d = ServiceOptsDict({"omero.share": "2","omero.user": "1"})
        assert d.get("omero.share") !=  None
        d.setOmeroShare()
        assert d.get("omero.share") ==  None
        assert d.get("omero.user") !=  None
        d.setOmeroUser()
        assert d.get("omero.user") ==  None
        
        try:
            d = ServiceOptsDict({"omero.group": True})
            d["omero.user"] = True
        except:
            pass
        else:
            self.fail("AttributeError: ServiceOptsDict argument must be a string, unicode or numeric type")
        
        try:
            d = ServiceOptsDict({"omero.group": []})
            d["omero.user"] = []
        except:
            pass
        else:
            self.fail("AttributeError: ServiceOptsDict argument must be a string, unicode or numeric type")
        
        try:
            d = ServiceOptsDict({"omero.group": {}})
            d["omero.user"] = {}
        except:
            pass
        else:
            self.fail("AttributeError: ServiceOptsDict argument must be a string, unicode or numeric type")
开发者ID:bramalingam,项目名称:openmicroscopy,代码行数:52,代码来源:test_utils.py


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