Major refactoring.
[pyyaml/python3.git] / tests / test_detector.py
blob661b24b37bf414f4f2407a5e626cc83b58c53dc9
2 import test_appliance
4 from yaml import *
6 class TestDetector(test_appliance.TestAppliance):
8 def _testDetector(self, test_name, data_filename, detect_filename):
9 node = None
10 correct_tag = None
11 try:
12 correct_tag = file(detect_filename, 'rb').read().strip()
13 node = compose(file(data_filename, 'rb'))
14 self.failUnless(isinstance(node, SequenceNode))
15 for scalar in node.value:
16 self.failUnless(isinstance(scalar, ScalarNode))
17 self.failUnlessEqual(scalar.tag, correct_tag)
18 except:
19 print
20 print "DATA:"
21 print file(data_filename, 'rb').read()
22 print "CORRECT_TAG:"
23 print file(detect_filename, 'rb').read()
24 print "ROOT NODE:", node
25 print "SCALAR NODES:", node.value
26 raise
28 TestDetector.add_tests('testDetector', '.data', '.detect')