コード例 #1
0
ファイル: test_element.py プロジェクト: aldanor/sidecar
 def test_getitem(self):
     assert Container('x')['foo', 'bar', 'baz'].children == ['foo', 'bar', 'baz']
     pytest.raises_str(TypeError, 'argument', lambda: Container['foo'])
     assert tags.p['foo'].children == ['foo']
     assert tags.p[('foo', 'bar')] == tags.p['foo', 'bar']
     assert tags.p['x', expr('y'), tags.hr, IO()].children == ['x', expr('y'), tags.hr, IO()]
     pytest.raises_str('unexpected child element: []', lambda: tags.p[[]])
コード例 #2
0
ファイル: test_element.py プロジェクト: aldanor/sidecar
 def test_expr(self):
     pytest.raises_str('invalid expr: 1', expr, 1)
     pytest.raises_str("invalid expr: ''", expr, '')
     assert expr(expr('foo')) == expr('foo')
     assert str(expr('bar')) == 'bar'
     assert repr(expr('bar')) == "expr('bar')"
     assert expr('baz').code == 'baz'
     assert {expr('foo'): 1} == {expr('foo'): 1}
コード例 #3
0
ファイル: test_element.py プロジェクト: aldanor/sidecar
 def test_input_overlap(self):
     with pytest.raises_str("overlapping inputs: ['j']"):
         tags.p[
             Container('x', inputs=['a'])[
                 Tag('i', 'a', b={'foo': Tag('j', 'b')}),
                 'foo'
             ],
             Container('y', inputs=['j'])
         ]
     with pytest.raises_str("overlapping inputs: ['i']"):
         tags.p[IO, IO()]
コード例 #4
0
ファイル: test_tags.py プロジェクト: aldanor/sidecar
 def test_duplicate_attrs(self):
     pytest.raises_str('duplicate attribute: srcDoc',
                       tags.p,
                       srcDoc='foo',
                       src_doc='foo')
     pytest.raises_str('duplicate attribute: className',
                       tags.p,
                       class_='foo',
                       className='foo')
     pytest.raises_str('duplicate attribute: className',
                       tags.p,
                       class_name='foo',
                       className='foo')
     pytest.raises_str('duplicate attribute: className',
                       tags.p,
                       class_='foo',
                       class_name='foo')
コード例 #5
0
ファイル: test_tags.py プロジェクト: aldanor/sidecar
 def test_duplicate_styles(self):
     pytest.raises_str('duplicate style: navUp',
                       tags.p,
                       style={
                           'nav-up': 'foo',
                           'navUp': 'foo'
                       })
     pytest.raises_str('duplicate style: navUp',
                       tags.p,
                       style={
                           'nav_up': 'foo',
                           'navUp': 'foo'
                       })
     pytest.raises_str('duplicate style: navUp',
                       tags.p,
                       style={
                           'nav-up': 'foo',
                           'nav_up': 'foo'
                       })
コード例 #6
0
ファイル: test_tags.py プロジェクト: aldanor/sidecar
 def test_invalid_attribute(self):
     pytest.raises_str('unknown attribute: bar', tags.p, bar='foo')
     pytest.raises_str('unknown attribute: bar', tags.p['baz'], bar='foo')
     pytest.raises_str('invalid attribute: href=42', tags.p, href=42)
コード例 #7
0
ファイル: test_tags.py プロジェクト: aldanor/sidecar
 def test_invalid_style(self):
     pytest.raises_str('invalid style: []', tags.p, style=[])
     pytest.raises_str('unknown style: foo', tags.p, style={'foo': 1})
     pytest.raises_str('invalid style: zIndex=[]',
                       tags.p,
                       style={'z-index': []})
コード例 #8
0
ファイル: test_element.py プロジェクト: aldanor/sidecar
 def test_allow_children(self):
     pytest.raises_str('not a container: Tag', lambda: Tag('i', 'a')['foo'])
     pytest.raises_str('not a container: hr', lambda: tags.hr['foo'])
     pytest.raises_str('not a container: hr', lambda: tags.hr(href='bar')['foo'])
コード例 #9
0
ファイル: test_element.py プロジェクト: aldanor/sidecar
 def test_encode_invalid(self):
     pytest.raises_str('not JSON serializable', Container(object()).to_json)
     pytest.raises_str('not JSON serializable', Container(object()).to_dict)