Ticket #143: test4.py

File test4.py, 476 bytes (added by berlin_lev@…, 5 years ago)

test to reproduce the error

Line 
1
2import yaml
3import re
4
5= """
6good: foo
7bad: |
8     foo"""
9
10
11class Test(yaml.YAMLObject):
12    yaml_tag = '!test'
13    pattern = re.compile(r'foo')
14    yaml.add_implicit_resolver('!test', pattern)
15
16    def __init__(self, s):
17        self.s = s
18    def __repr__(self):
19        return 'Test(%s)' % self.s
20
21    @classmethod
22    def from_yaml(cls, loader, node):
23        value = loader.construct_scalar(node)
24        return cls(value)
25
26print yaml.load(s)