Ejemplo n.º 1
0
def test_version():
    "confirm parse displays expected version"
    expected_version = ' '.join(
        ('Kata Bank OCR Parser', 'version', __version__))
    found_version = subprocess.check_output([Paths.parse(),
                                             '--version']).rstrip('\n')
    assert expected_version == found_version
Ejemplo n.º 2
0
def test_stdin_and_stdout(expectations_and_source):
    "confirm Results parsed correctly from StdIn to StdOut"
    expected_results, input_path = expectations_and_source
    with open(input_path) as input_file:
        found_results = subprocess.check_output([Paths.parse(), '-'],
                                                stdin=input_file)
    assert expected_results == found_results
Ejemplo n.º 3
0
def test_in_path_and_out_path(tmpdir, expectations_and_source):
    "confirm Results parsed correctly from in_path to out_path"
    expected_results, input_path = expectations_and_source
    output_path = str(tmpdir.join('tmp_out_file'))
    subprocess.call([Paths.parse(), input_path, output_path])
    with open(output_path) as parsed_results:
        found_results = parsed_results.read()
    assert expected_results == found_results
Ejemplo n.º 4
0
def test_in_path_and_out_path(tmpdir, expectations_and_source):
    "confirm Results parsed correctly from in_path to out_path"
    expected_results, input_path = expectations_and_source
    output_path = str(tmpdir.join('tmp_out_file'))
    subprocess.call([Paths.parse(), input_path, output_path])
    with open(output_path) as parsed_results:
        found_results = parsed_results.read()
    assert expected_results == found_results
Ejemplo n.º 5
0
def test_stdin_and_out_path(tmpdir, expectations_and_source):
    "confirm Results parsed correctly from StdIn to out_path"
    expected_results, input_path = expectations_and_source
    output_path = str(tmpdir.join('tmp_out_file'))
    with open(input_path) as input_file:
        subprocess.call([Paths.parse(), '-', output_path], stdin=input_file)
    with open(output_path) as parsed_results:
        found_results = parsed_results.read()
    assert expected_results == found_results
Ejemplo n.º 6
0
def test_stdin_and_out_path(tmpdir, expectations_and_source):
    "confirm Results parsed correctly from StdIn to out_path"
    expected_results, input_path = expectations_and_source
    output_path = str(tmpdir.join('tmp_out_file'))
    with open(input_path) as input_file:
        subprocess.call([Paths.parse(), '-', output_path], stdin=input_file)
    with open(output_path) as parsed_results:
        found_results = parsed_results.read()
    assert expected_results == found_results
Ejemplo n.º 7
0
def test_help(argument):
    "confirm parse --help displays expected docstring"
    expected_docstring = __doc__
    found_docstring = subprocess.check_output([Paths.parse(), argument])
    assert expected_docstring.split() == found_docstring.split()
Ejemplo n.º 8
0
def test_version():
    "confirm parse displays expected version"
    expected_version = ' '.join(('Kata Bank OCR Parser', 'version', __version__))
    found_version = subprocess.check_output([Paths.parse(), '--version']).rstrip('\n')
    assert expected_version == found_version
Ejemplo n.º 9
0
def test_in_path_and_stdout(expectations_and_source):
    "confirm Results parsed correctly from path to StdOut"
    expected_results, input_path = expectations_and_source
    found_results = subprocess.check_output([Paths.parse(), input_path])
    assert expected_results == found_results
Ejemplo n.º 10
0
def test_stdin_and_stdout(expectations_and_source):
    "confirm Results parsed correctly from StdIn to StdOut"
    expected_results, input_path = expectations_and_source
    with open(input_path) as input_file:
        found_results = subprocess.check_output([Paths.parse(), '-'], stdin=input_file)
    assert expected_results == found_results
Ejemplo n.º 11
0
"Test Parse module"

import pytest
import subprocess

from parse.options import __doc__, __version__
import parse

from fixture_methods import Results, Paths

@pytest.fixture(params=(
        (Results.of_basic_input_file(), Paths.basic_input_file()),
        (Results.of_advanced_input_file(), Paths.advanced_input_file()),
        ))
def expectations_and_source(request):
    "return expected results and input path from which to find them"
    expected_results, path = request.param
    expected_results = '\n'.join(expected_results) + '\n'
    return expected_results, path

def test_stdin_and_stdout(expectations_and_source):
    "confirm Results parsed correctly from StdIn to StdOut"
    expected_results, input_path = expectations_and_source
    with open(input_path) as input_file:
        found_results = subprocess.check_output([Paths.parse(), '-'], stdin=input_file)
    assert expected_results == found_results

def test_in_path_and_stdout(expectations_and_source):
    "confirm Results parsed correctly from path to StdOut"
    expected_results, input_path = expectations_and_source
    found_results = subprocess.check_output([Paths.parse(), input_path])
"test the entries_from_path generator"

import pytest
from toolz import count, pipe

from parse.generators.entries_from_path import entries_from_path

from fixture_methods import Paths, Entries


path = Paths.basic_input_file()
entries = Entries.of_basic_input_file()

def test_with_bad_path():
    "confirm a bad path raises an expected error"
    iterator = entries_from_path('bad_path_string')
    pytest.raises((OSError, IOError,), tuple, iterator)

def test_line_count_of_known_input():
    "confirm all Lines read from basic input file"
    expected_entry_count = count(entries)
    found_entry_count = pipe(path, entries_from_path, count)
    assert expected_entry_count == found_entry_count

def test_known_lines_grouped_to_known_entries():
    "confirm known lines grouped into known entries"
    found_entries = entries_from_path(path)
    assert tuple(entries) == tuple(found_entries)
Ejemplo n.º 13
0
def test_help(argument):
    "confirm parse --help displays expected docstring"
    expected_docstring = __doc__
    found_docstring = subprocess.check_output([Paths.parse(), argument])
    assert expected_docstring.split() == found_docstring.split()
Ejemplo n.º 14
0
def test_in_path_and_stdout(expectations_and_source):
    "confirm Results parsed correctly from path to StdOut"
    expected_results, input_path = expectations_and_source
    found_results = subprocess.check_output([Paths.parse(), input_path])
    assert expected_results == found_results
Ejemplo n.º 15
0
"Test Parse module"

import pytest
import subprocess

from parse.options import __doc__, __version__
import parse

from fixture_methods import Results, Paths


@pytest.fixture(params=(
    (Results.of_basic_input_file(), Paths.basic_input_file()),
    (Results.of_advanced_input_file(), Paths.advanced_input_file()),
))
def expectations_and_source(request):
    "return expected results and input path from which to find them"
    expected_results, path = request.param
    expected_results = '\n'.join(expected_results) + '\n'
    return expected_results, path


def test_stdin_and_stdout(expectations_and_source):
    "confirm Results parsed correctly from StdIn to StdOut"
    expected_results, input_path = expectations_and_source
    with open(input_path) as input_file:
        found_results = subprocess.check_output([Paths.parse(), '-'],
                                                stdin=input_file)
    assert expected_results == found_results