コード例 #1
0
 def get_or_create_access_handle(self, obj):
     id_ = id(obj)
     try:
         return self.get_access_handle(id_)
     except KeyError:
         access = DirectObjectAccess(self._inference_state_weakref(), obj)
         handle = AccessHandle(self, access, id_)
         self.set_access_handle(handle)
         return handle
コード例 #2
0
def test_parent_context(same_process_inference_state, attribute, expected_name,
                        expected_parent):
    import decimal

    class C:
        x = 1
        y = int
        z = True
        cos = math.cos
        dec = decimal.Decimal(1)
        dt = datetime(2000, 1, 1)
        ret_int = _return_int

    o = compiled.CompiledValue(
        same_process_inference_state,
        DirectObjectAccess(same_process_inference_state, C))
    x, = o.py__getattribute__(attribute)
    assert x.py__name__() == expected_name
    module_name = x.parent_context.py__name__()
    assert module_name == expected_parent
    assert x.parent_context.parent_context is None
コード例 #3
0
ファイル: test_compiled.py プロジェクト: mikev1963/dotfiles
def test_qualified_names(same_process_inference_state, obj, expected_names):
    o = compiled.CompiledValue(
        same_process_inference_state,
        DirectObjectAccess(same_process_inference_state, obj)
    )
    assert o.get_qualified_names() == tuple(expected_names)