| Revision 330,
1.1 KB
checked in by xi, 4 years ago
(diff) |
|
Share data files between Py2 and Py3 test suites.
|
| Line | |
|---|
| 1 | |
|---|
| 2 | import yaml, canonical |
|---|
| 3 | |
|---|
| 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 |
|---|
| 11 | |
|---|
| 12 | test_canonical_scanner.unittest = ['.canonical'] |
|---|
| 13 | |
|---|
| 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 |
|---|
| 21 | |
|---|
| 22 | test_canonical_parser.unittest = ['.canonical'] |
|---|
| 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
TracBrowser
for help on using the repository browser.