pyyaml / tests / lib / test_canonical.py

import yaml, canonical

def test_canonical_scanner(canonical_filename, verbose=False):
    data = open(canonical_filename, 'rb').read()
    tokens = list(yaml.canonical_scan(data))
    assert tokens, tokens
    if verbose:
        for token in tokens:
            print token

test_canonical_scanner.unittest = ['.canonical']

def test_canonical_parser(canonical_filename, verbose=False):
    data = open(canonical_filename, 'rb').read()
    events = list(yaml.canonical_parse(data))
    assert events, events
    if verbose:
        for event in events:
            print event

test_canonical_parser.unittest = ['.canonical']

def test_canonical_error(data_filename, canonical_filename, verbose=False):
    data = open(data_filename, 'rb').read()
    try:
        output = list(yaml.canonical_load_all(data))
    except yaml.YAMLError, exc:
        if verbose:
            print exc
    else:
        raise AssertionError("expected an exception")

test_canonical_error.unittest = ['.data', '.canonical']
test_canonical_error.skip = ['.empty']

if __name__ == '__main__':
    import test_appliance
    test_appliance.run(globals())
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.