Exemple #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='>')"
Exemple #2
0
 def __repr__(self):
     r = ReprHelper(self)
     r.parantheses = ('<', '>')
     r.positional_from_attr('_engine')
     return str(r)
Exemple #3
0
 def __repr__(self):
     r = ReprHelper(self)
     r.parantheses = ('<', '>')
     r.keyword_from_attr('controller')
     return str(r)
Exemple #4
0
 def __repr__(self):
     r = ReprHelper(self)
     r.parantheses = ('<', '>')
     r.keyword_from_attr('identity')
     return str(r)
Exemple #5
0
 def __repr__(self):
     r = ReprHelper(self)
     self._repr_helper(r)
     return str(r)
Exemple #6
0
 def __repr__(self):
     r = ReprHelper(self)
     r.parantheses = ('<', '>')
     r.keyword_with_value('id', hex(id(self)), raw=True)
     return str(r)
Exemple #7
0
 def __repr__(self):
     r = ReprHelper(self)
     r.parantheses = ('<', '>')
     r.keyword_from_attr('identity')
     return str(r)