<s> import libpry <EOL> import libpry . explain as explain <EOL> class uExpression ( libpry . AutoTree ) : <EOL> def test_show ( self ) : <EOL> e = explain . Expression ( "<STR_LIT>" ) <EOL> s = e . show ( dict ( a = <NUM_LIT:1> , b = <NUM_LIT:2> ) , { } ) <EOL> assert s == "<STR_LIT:3>" <EOL> class uExplain ( libpry . AutoTree ) : <EOL> def setUp ( self ) : <EOL> self . s = explain . Explain ( ) <EOL> def test_simple ( self ) : <EOL> r , s = self . s . parseExpression ( "<STR_LIT>" ) <EOL> assert r == [ <EOL> explain . Expression ( "<STR_LIT:1>" ) , <EOL> "<STR_LIT>" , <EOL> explain . Expression ( "<STR_LIT:1>" ) , <EOL> ] <EOL> def test_parens ( self ) : <EOL> r , s = self . s . parseExpression ( "<STR_LIT>" ) <EOL> assert r == [ <EOL> explain . Expression ( '<STR_LIT:True>' ) , <EOL> '<STR_LIT>' , <EOL> explain . Expression ( '<STR_LIT>' ) <EOL> ] <EOL> r , s = self . s . parseExpression ( "<STR_LIT>" ) <EOL> assert r == [ <EOL> explain . Expression ( '<STR_LIT:True>' ) , <EOL> '<STR_LIT>' , <EOL> explain . Expression ( '<STR_LIT>' ) <EOL> ] <EOL> def test_unary ( self ) : <EOL> r , s = self . s . parseExpression ( "<STR_LIT>" ) <EOL> assert r == [ <EOL> explain . Expression ( '<STR_LIT>' ) <EOL> ] <EOL> r , s = self . s . parseExpression ( "<STR_LIT>" ) <EOL> assert r == [ <EOL> explain . Expression ( '<STR_LIT>' ) <EOL> ] <EOL> def test_not ( self ) : <EOL> r , s = self . s . parseExpression ( "<STR_LIT>" ) <EOL> assert r == [ <EOL> "<STR_LIT>" , <EOL> explain . Expression ( '<STR_LIT>' ) <EOL> ] <EOL> def test_and ( self ) : <EOL> r , s = self . s . parseExpression ( "<STR_LIT>" ) <EOL> expected = [ <EOL> explain . Expression ( '<STR_LIT:a>' ) , <EOL> '<STR_LIT>' , <EOL> explain . Expression ( '<STR_LIT:b>' ) , <EOL> '<STR_LIT>' , <EOL> explain . Expression ( '<STR_LIT:c>' ) , <EOL> '<STR_LIT>' , <EOL> explain . Expression ( '<STR_LIT:d>' ) <EOL> ] <EOL> assert r == expected <EOL> def test_comma ( self ) : <EOL> r , s = self . s . parseExpression ( "<STR_LIT>" ) <EOL> expected = [ <EOL> explain . Expression ( '<STR_LIT:a>' ) , <EOL> '<STR_LIT>' , <EOL> explain . Expression ( '<STR_LIT:b>' ) , <EOL> '<STR_LIT>' , <EOL> explain . Expression ( '<STR_LIT:c>' ) , <EOL> '<STR_LIT>' , <EOL> explain . Expression ( '<STR_LIT:d>' ) <EOL> ] <EOL> assert r == expected <EOL> def test_unbalanced ( self ) : <EOL> assert not self . s . parseExpression ( "<STR_LIT>" ) [ <NUM_LIT:0> ] <EOL> assert not self . s . parseExpression ( "<STR_LIT>" ) [ <NUM_LIT:0> ] <EOL> assert not self . s . parseExpression ( "<STR_LIT>" ) [ <NUM_LIT:0> ] <EOL> def test_list ( self ) : <EOL> r , s = self . s . parseExpression ( '<STR_LIT>' ) <EOL> expected = [ <EOL> explain . Expression ( '<STR_LIT>' ) , <EOL> ] <EOL> assert r == expected <EOL> def test_str ( self ) : <EOL> r = explain . Explain ( <EOL> "<STR_LIT>" , <EOL> dict ( a = <NUM_LIT:1> , b = <NUM_LIT:2> , c = <NUM_LIT:3> , d = <NUM_LIT:4> ) , <EOL> dict ( ) <EOL> ) <EOL> assert "<STR_LIT>" in str ( r ) <EOL> tests = [ <EOL> uExpression ( ) , <EOL> uExplain ( ) <EOL> ] </s>
