Ejemplo n.º 1
0
 def check_evaluate(self, dir, block, expected):
     parser = FileParser('td')
     compare(expected, actual=parser.evaluate(Mock(
         parsed=block,
         namespace={'td': dir},
         path='/the/file',
         line=42,
     )))
Ejemplo n.º 2
0
 def check_evaluate(self, dir, block, expected):
     parser = FileParser('td')
     compare(expected, actual=parser.evaluate(Mock(
         parsed=block,
         namespace={'td': dir},
         path='/the/file',
         line=42,
     )))
Ejemplo n.º 3
0
 def check_document(self, text, expected):
     d = Document(dedent(text), path='/dev/null')
     compare(list(r.parsed for r in FileParser('td')(d)), expected=expected)
Ejemplo n.º 4
0
from doctest import REPORT_NDIFF, ELLIPSIS

from sybil import Sybil
from sybil.parsers.doctest import DocTestParser, FIX_BYTE_UNICODE_REPR
from sybil.parsers.codeblock import CodeBlockParser
from sybil.parsers.capture import parse_captures

from testfixtures.sybil import FileParser

pytest_collect_file = Sybil(
    parsers=[
        DocTestParser(optionflags=REPORT_NDIFF | ELLIPSIS
                      | FIX_BYTE_UNICODE_REPR),
        CodeBlockParser(['print_function']),
        parse_captures,
        FileParser('tempdir'),
    ],
    pattern='*.txt',
).pytest()
Ejemplo n.º 5
0
    sys.path.append(dir.path)
    namespace['db_url'] = db_url = 'sqlite:///' + join(dir.path, 'test.db')
    # make sample package
    dir.write('sample/__init__.py', b'')
    dir.write('sample/config.py', ("""
db_url = %r
is_production = False
""" % db_url).encode('ascii'))


def teardown(namespace):
    dir = namespace['dir']
    sys.path.remove(dir.path)
    dir.cleanup_all()
    namespace['tb'].restore()


pytest_collect_file = Sybil(
    parsers=[
        DocTestParser(optionflags=REPORT_NDIFF | ELLIPSIS
                      | FIX_BYTE_UNICODE_REPR),
        parse_captures,
        CodeBlockParser(['print_function']),
        FileParser('dir'),
        parse_bash_blocks,
    ],
    pattern='*.txt',
    setup=setup,
    teardown=teardown,
).pytest()