Пример #1
0
def make_paramters(module_names, file_path=__file__):
    """Create parameters for py.test.generated tests.

    Creates a generator with pairs of functions.
    The first function is to be tested and the second functions returns
    th expected result of the first function.
    Converted into a list it would like this:
    [<function func_1>, <function result_func_1>,
     <function func_2>, <function result_func_2>,
     ...
     <function func_n>, <function result_func_n>,]
    """
    modules = [get_module(m_name, file_path) for m_name in module_names]
    params = (auto_test(module) for module in modules)
    return it.chain(*params)  # pylint: disable=star-args
Пример #2
0
def make_paramters(module_names, file_path=__file__):
    """Create parameters for py.test.generated tests.

    Creates a generator with pairs of functions.
    The first function is to be tested and the second functions returns
    th expected result of the first function.
    Converted into a list it would like this:
    [<function func_1>, <function result_func_1>,
     <function func_2>, <function result_func_2>,
     ...
     <function func_n>, <function result_func_n>,]
    """
    modules = [get_module(m_name, file_path) for m_name in module_names]
    params = (auto_test(module) for module in modules)
    return it.chain(*params)  # pylint: disable=star-args
Пример #3
0
import os
from functools import partial

import pytest

from mochi.utils.pycloader import get_function, get_module

from conftest import auto_test

get_module = partial(get_module, file_path=__file__)
get_function = partial(get_function, file_path=__file__)

factorial = get_function('factorial')
fizzbuzz = get_function('fizzbuzz')
patterns = get_module('patterns')


def test_factorial_1():
    assert factorial(1) == 1


def test_factorial_2():
    assert factorial(2) == 2


def test_fizzbuzz():
    res = [1, 2, 'fizz', 4, 'buzz', 'fizz', 7, 8, 'fizz', 'buzz', 11, 'fizz',
           13, 14, 'fizzbuzz', 16, 17, 'fizz', 19, 'buzz', 'fizz', 22, 23,
           'fizz', 'buzz', 26, 'fizz', 28, 29, 'fizzbuzz']
    assert [fizzbuzz(n) for n in range(1, 31)] == res
Пример #4
0
# file test_add.py in dir tests

from mochi.utils.pycloader import get_module


mod_add = get_module('add', file_path=__file__)


def test_add():
    assert mod_add.add(2, 2) == 4


def test_add10():
    assert mod_add.add10(2) == 12