Skip to content

Commit

Permalink
TempyRepr root evaluator tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Hrabal committed Nov 1, 2017
1 parent 7701168 commit e7d06e0
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/test_TempyREPR.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,20 @@ def repr(self):
inst = Obj()
self.assertEqual(Pre()(Span(), A()(inst)).render(), '<pre><span></span><a>footest</a></pre>')
self.assertEqual(Pre()(Div(), Div()(inst)).render(), '<pre><div></div><div>bar</div></pre>')

def test_root(self):
class Obj:
foo = 'foo'
bar = 'bar'

class Div(TempyREPR):
def repr(self):
self(self.bar)

class Pre(TempyREPR):
def repr(self):
self(self.foo + 'test')

inst = Obj()
self.assertEqual(Pre()(Span()(A()(inst))).render(), '<pre><span><a>footest</a></span></pre>')
self.assertEqual(Pre()(Span()(Div()(inst))).render(), '<pre><span><div>bar</div></span></pre>')

0 comments on commit e7d06e0

Please sign in to comment.