예제 #1
0
    def it_can_construct_from_seq_of_head_body_pairs(self, from_seq_fixture):
        head_body_pairs = from_seq_fixture

        productions = Productions.from_seq(*head_body_pairs)

        ps = productions._productions
        for idx, (head, body) in enumerate(head_body_pairs):
            production = ps[idx]
            assert type(production) is Production
            assert production.head is head
            assert production.body is body
예제 #2
0
    def it_can_construct_from_seq_of_head_body_pairs(self, from_seq_fixture):
        head_body_pairs = from_seq_fixture

        productions = Productions.from_seq(*head_body_pairs)

        ps = productions._productions
        for idx, (head, body) in enumerate(head_body_pairs):
            production = ps[idx]
            assert type(production) is Production
            assert production.head is head
            assert production.body is body
예제 #3
0
 def it_raises_on_attempt_to_create_a_new_attribute(self):
     productions = Productions(())
     with pytest.raises(AttributeError):
         productions.new_attr = '9'
예제 #4
0
 def it_can_get_the_productions_for_a_head_symbol(self, getitem_fixture):
     production_seq, key, expected_productions = getitem_fixture
     productions = Productions(production_seq)
     assert list(productions[key]) == expected_productions
예제 #5
0
 def it_raises_on_attempt_to_create_a_new_attribute(self):
     productions = Productions(())
     with pytest.raises(AttributeError):
         productions.new_attr = '9'