def test_parse_valid_blueprint_with_source_maps(self): parse_result = draughtsman.parse('# My API', generate_source_map=True) self.assertIsInstance(parse_result, ParseResult) self.assertEqual(parse_result.api.title.defract, 'My API') self.assertEqual( parse_result.api.title.attributes.get('sourceMap').defract, [[[0, 8]]] )
from draughtsman import parse bp = """ FORMAT: 1A # My API """ parse(bp)
def test_parse_valid_blueprint(self): parse_result = draughtsman.parse('# My API') self.assertIsInstance(parse_result, ParseResult) self.assertEqual(parse_result.api.title.defract, 'My API')
import sys import code from draughtsman import parse if len(sys.argv) != 2: print('Usage: {} <file>'.format(sys.argv[0])) exit(0) with open(sys.argv[1]) as fp: parse_result = parse(fp.read()) banner = '>>> parse_result\n{}'.format(repr(parse_result)) code.interact(banner=banner, local={'parse_result': parse_result})