source: pyyaml/trunk/tests/test_detector.py @ 136

Revision 136, 933 bytes checked in by xi, 8 years ago (diff)

Major refactoring.

RevLine 
[55]1
2import test_appliance
3
[136]4from yaml import *
[55]5
6class TestDetector(test_appliance.TestAppliance):
7
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()
[136]13            node = compose(file(data_filename, 'rb'))
[55]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
27
28TestDetector.add_tests('testDetector', '.data', '.detect')
29
Note: See TracBrowser for help on using the repository browser.