| Revision 136,
933 bytes
checked in by xi, 7 years ago
(diff) |
|
Major refactoring.
|
| Line | |
|---|
| 1 | |
|---|
| 2 | import test_appliance |
|---|
| 3 | |
|---|
| 4 | from yaml import * |
|---|
| 5 | |
|---|
| 6 | class 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() |
|---|
| 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 |
|---|
| 27 | |
|---|
| 28 | TestDetector.add_tests('testDetector', '.data', '.detect') |
|---|
| 29 | |
|---|
Note: See
TracBrowser
for help on using the repository browser.