Example #1
0
def test_helper_parantheses():
    class A(object):
        def __repr__(self):
            r = ReprHelper(self)
            r.parantheses = ('<', '>')
            r.keyword_with_value('id', hex(id(self)), raw=True)
            return str(r)

        def _repr_pretty_(self, p, cycle):
            r = PrettyReprHelper(self, p, cycle)
            r.parantheses = ('<', '>')
            with r:
                r.keyword_with_value('id', hex(id(self)), raw=True)

    a = A()
    assert repr(a) == 'A<id={}>'.format(hex(id(a)))
    assert pretty(a) == 'A<id={}>'.format(hex(id(a)))

    # Test namedtuple for parantheses property
    r = ReprHelper(a)
    assert repr(r.parantheses) == "Parantheses(left='(', right=')')"
    r.parantheses = ('<', '>')
    assert repr(r.parantheses) == "Parantheses(left='<', right='>')"
Example #2
0
 def __repr__(self):
     r = ReprHelper(self)
     r.parantheses = ('<', '>')
     r.positional_from_attr('_engine')
     return str(r)
Example #3
0
 def __repr__(self):
     r = ReprHelper(self)
     r.parantheses = ('<', '>')
     r.keyword_from_attr('controller')
     return str(r)
Example #4
0
 def __repr__(self):
     r = ReprHelper(self)
     r.parantheses = ('<', '>')
     r.keyword_from_attr('identity')
     return str(r)
Example #5
0
 def __repr__(self):
     r = ReprHelper(self)
     r.parantheses = ('<', '>')
     r.keyword_with_value('id', hex(id(self)), raw=True)
     return str(r)
Example #6
0
 def __repr__(self):
     r = ReprHelper(self)
     r.parantheses = ('<', '>')
     r.keyword_from_attr('identity')
     return str(r)