| Revision 330,
1.1 KB
checked in by xi, 4 years ago
(diff) |
|
Share data files between Py2 and Py3 test suites.
|
| Rev | Line | |
|---|
| [43] | 1 | |
|---|
| [322] | 2 | import yaml, canonical |
|---|
| [43] | 3 | |
|---|
| [322] | 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: |
|---|
| [328] | 10 | print(token) |
|---|
| [43] | 11 | |
|---|
| [322] | 12 | test_canonical_scanner.unittest = ['.canonical'] |
|---|
| [43] | 13 | |
|---|
| [322] | 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: |
|---|
| [328] | 20 | print(event) |
|---|
| [43] | 21 | |
|---|
| [322] | 22 | test_canonical_parser.unittest = ['.canonical'] |
|---|
| [43] | 23 | |
|---|
| [322] | 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)) |
|---|
| [328] | 28 | except yaml.YAMLError as exc: |
|---|
| [322] | 29 | if verbose: |
|---|
| [328] | 30 | print(exc) |
|---|
| [322] | 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.