File: test_compatibility.py

package info (click to toggle)
python-sybil 9.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,148 kB
  • sloc: python: 4,510; makefile: 90
file content (33 lines) | stat: -rw-r--r-- 1,076 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# Tests for backwards compatibility
import json

from sybil.parsers.capture import parse_captures
from sybil.parsers.codeblock import CodeBlockParser, PythonCodeBlockParser
from sybil.parsers.skip import skip
from .helpers import parse


def test_imports():
    # uncomment once all the moves are done!
    from sybil.parsers.capture import parse_captures
    from sybil.parsers.codeblock import CodeBlockParser, PythonCodeBlockParser
    from sybil.parsers.doctest import DocTestParser
    from sybil.parsers.skip import skip
    pass


def test_code_block_parser_pad():
    assert CodeBlockParser('foo').pad('x', line=2) == '\n\nx'


def test_skip_parser_function():
    examples, namespace = parse('skip.txt', PythonCodeBlockParser(), skip, expected=9)
    for example in examples:
        example.evaluate()
    assert namespace['run'] == [2, 5]


def test_capture_parser_function():
    examples, namespace = parse('capture_codeblock.txt', parse_captures, expected=1)
    examples[0].evaluate()
    assert json.loads(namespace['json']) == {"a key": "value", "b key": 42}