예제 #1
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
예제 #2
0
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)