Changeset 322 for pyyaml/trunk/tests/test_canonical.py
- Timestamp:
- 12/28/08 15:16:50 (4 years ago)
- File:
-
- 1 edited
-
pyyaml/trunk/tests/test_canonical.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
pyyaml/trunk/tests/test_canonical.py
r136 r322 1 1 2 import test_appliance2 import yaml, canonical 3 3 4 class TestCanonicalAppliance(test_appliance.TestAppliance): 4 def test_canonical_scanner(canonical_filename, verbose=False): 5 data = open(canonical_filename, 'rb').read() 6 tokens = list(yaml.canonical_scan(data)) 7 assert tokens, tokens 8 if verbose: 9 for token in tokens: 10 print token 5 11 6 def _testCanonicalScanner(self, test_name, canonical_filename): 7 data = file(canonical_filename, 'rb').read() 8 tokens = list(test_appliance.canonical_scan(data)) 9 #for token in tokens: 10 # print token 12 test_canonical_scanner.unittest = ['.canonical'] 11 13 12 def _testCanonicalParser(self, test_name, canonical_filename): 13 data = file(canonical_filename, 'rb').read() 14 event = list(test_appliance.canonical_parse(data)) 15 #for event in events: 16 # print event 14 def test_canonical_parser(canonical_filename, verbose=False): 15 data = open(canonical_filename, 'rb').read() 16 events = list(yaml.canonical_parse(data)) 17 assert events, events 18 if verbose: 19 for event in events: 20 print event 17 21 18 TestCanonicalAppliance.add_tests('testCanonicalScanner', '.canonical') 19 TestCanonicalAppliance.add_tests('testCanonicalParser', '.canonical') 22 test_canonical_parser.unittest = ['.canonical'] 20 23 24 def test_canonical_error(data_filename, canonical_filename, verbose=False): 25 data = open(data_filename, 'rb').read() 26 try: 27 output = list(yaml.canonical_load_all(data)) 28 except yaml.YAMLError, exc: 29 if verbose: 30 print exc 31 else: 32 raise AssertionError("expected an exception") 33 34 test_canonical_error.unittest = ['.data', '.canonical'] 35 test_canonical_error.skip = ['.empty'] 36 37 if __name__ == '__main__': 38 import test_appliance 39 test_appliance.run(globals()) 40
Note: See TracChangeset
for help on using the changeset viewer.
