4 from yaml
.reader
import Reader
5 from yaml
.scanner
import Scanner
6 from yaml
.parser
import *
7 from yaml
.composer
import *
8 from yaml
.resolver
import *
9 from yaml
.nodes
import *
11 class TestDetector(test_appliance
.TestAppliance
):
13 def _testDetector(self
, test_name
, data_filename
, detect_filename
):
17 correct_tag
= file(detect_filename
, 'rb').read().strip()
18 resolver
= Resolver(Composer(Parser(Scanner(Reader(file(data_filename
, 'rb'))))))
19 node
= list(iter(resolver
))[0]
20 self
.failUnless(isinstance(node
, SequenceNode
))
21 for scalar
in node
.value
:
22 self
.failUnless(isinstance(scalar
, ScalarNode
))
23 self
.failUnlessEqual(scalar
.tag
, correct_tag
)
27 print file(data_filename
, 'rb').read()
29 print file(detect_filename
, 'rb').read()
30 print "ROOT NODE:", node
31 print "SCALAR NODES:", node
.value
34 TestDetector
.add_tests('testDetector', '.data', '.detect')