Ignore:
Timestamp:
12/28/08 15:16:50 (5 years ago)
Author:
xi
Message:

Refactored the test suite; updated include and library paths in setup.cfg.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pyyaml/trunk/tests/test_canonical.py

    r136 r322  
    11 
    2 import test_appliance 
     2import yaml, canonical 
    33 
    4 class TestCanonicalAppliance(test_appliance.TestAppliance): 
     4def 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 
    511 
    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 
     12test_canonical_scanner.unittest = ['.canonical'] 
    1113 
    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 
     14def 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 
    1721 
    18 TestCanonicalAppliance.add_tests('testCanonicalScanner', '.canonical') 
    19 TestCanonicalAppliance.add_tests('testCanonicalParser', '.canonical') 
     22test_canonical_parser.unittest = ['.canonical'] 
    2023 
     24def 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 
     34test_canonical_error.unittest = ['.data', '.canonical'] 
     35test_canonical_error.skip = ['.empty'] 
     36 
     37if __name__ == '__main__': 
     38    import test_appliance 
     39    test_appliance.run(globals()) 
     40 
Note: See TracChangeset for help on using the changeset viewer.