2 import unittest
, test_appliance
6 class TestExtVersion(unittest
.TestCase
):
8 def testExtVersion(self
):
9 self
.failUnlessEqual("%s.%s.%s" % _yaml
.get_version(), _yaml
.get_version_string())
11 class TestExtScanner(test_appliance
.TestAppliance
):
13 def _testExtScanner(self
, test_name
, data_filename
, canonical_filename
):
14 data
= file(data_filename
, 'r').read()
15 tokens
= list(yaml
.scan(data
))
18 for token
in yaml
.scan(data
, Loader
=yaml
.ExtLoader
):
19 ext_tokens
.append(token
)
20 self
.failUnlessEqual(len(tokens
), len(ext_tokens
))
21 for token
, ext_token
in zip(tokens
, ext_tokens
):
22 self
.failUnlessEqual(token
.__class
__, ext_token
.__class
__)
23 self
.failUnlessEqual((token
.start_mark
.index
, token
.start_mark
.line
, token
.start_mark
.column
),
24 (ext_token
.start_mark
.index
, ext_token
.start_mark
.line
, ext_token
.start_mark
.column
))
25 self
.failUnlessEqual((token
.end_mark
.index
, token
.end_mark
.line
, token
.end_mark
.column
),
26 (ext_token
.end_mark
.index
, ext_token
.end_mark
.line
, ext_token
.end_mark
.column
))
27 if hasattr(token
, 'value'):
28 self
.failUnlessEqual(token
.value
, ext_token
.value
)
32 print file(data_filename
, 'rb').read()
33 print "TOKENS:", tokens
34 print "EXT_TOKENS:", ext_tokens
37 TestExtScanner
.add_tests('testExtScanner', '.data', '.canonical')
39 def main(module
='__main__'):
42 if __name__
== '__main__':