Exemplo n.º 1
0
def test_generate_docs_string():
    path = os.path.join(_basepath, 'single_line_comment.py')
    src = Source(path)
    result = src.generate_docs(
        BaseTemplate(),
        BaseFormatter(),
        BaseHighlighter(),
        None)
    outfile = ''.join([
        'def this_is_some_code():\n',
        ' This is a single line comment\n',
        '    pass\n'])
    assert result == outfile
Exemplo n.º 2
0
def test_generate_docs_file():
    path = os.path.join(_basepath, 'single_line_comment.py')
    src = Source(path)
    src.generate_docs(
        BaseTemplate(),
        BaseFormatter(),
        BaseHighlighter(),
        os.path.join('test', 'test_out'))
    outpath = os.path.join(
        'test',
        'test_out',
        _basepath,
        'single_line_comment')
    outfile = [
        'def this_is_some_code():\n',
        ' This is a single line comment\n',
        '    pass\n']

    with open(outpath, 'r') as f:
        lines = f.readlines()

    for outline, writtenline in zip(outfile, lines):
        assert outline == writtenline, '%r %r' % (outline, writtenline)