Exemplo n.º 1
0
 def test_2(self):
     '''test that sequence_node_from_tokens works when there is no item'''
     self.assertEqual(
         sequence_node_from_tokens(tokens=[
             SequenceStart(),
             SequenceEnd(),
         ],
                                   start=0), (SequenceNode(items=[]), 2))
Exemplo n.º 2
0
 def test_1(self):
     '''test that sequence_node_from_tokens works for the simplest case'''
     self.assertEqual(
         sequence_node_from_tokens(tokens=[
             SequenceStart(),
             ScalarValue(data='value'),
             SequenceEnd(),
         ],
                                   start=0),
         (SequenceNode(items=[ScalarNode(data='value')]), 3))
Exemplo n.º 3
0
 def test_4(self):
     '''test that sequence_node_from_tokens works with there is a nested sequence'''
     self.assertEqual(
         sequence_node_from_tokens(tokens=[
             SequenceStart(),
             SequenceStart(),
             ScalarValue(data='value'),
             SequenceEnd(),
             SequenceEnd(),
         ],
                                   start=0),
         (SequenceNode(
             items=[SequenceNode(items=[ScalarNode(data='value')])]), 5))
Exemplo n.º 4
0
 def test_3(self):
     '''test that sequence_node_from_tokens works with more than one item'''
     self.assertEqual(
         sequence_node_from_tokens(tokens=[
             SequenceStart(),
             ScalarValue(data='value'),
             Delimiter(),
             ScalarValue(data='value'),
             SequenceEnd(),
         ],
                                   start=0),
         (SequenceNode(
             items=[ScalarNode(data='value'),
                    ScalarNode(data='value')]), 5))
Exemplo n.º 5
0
 def test_5(self):
     '''test that sequence_node_from_tokens works with it contains a mapping'''
     self.assertEqual(
         sequence_node_from_tokens(tokens=[
             SequenceStart(),
             MappingStart(),
             ScalarValue(data='key'),
             Separator(),
             ScalarValue(data='value'),
             MappingEnd(),
             SequenceEnd(),
         ],
                                   start=0),
         (SequenceNode(items=[
             MappingNode(
                 mapping={ScalarNode(data='key'): ScalarNode(data='value')})
         ]), 7))