Example #1
0
def pytest_runtest_setup(item):
    """
    pytest builtin hook
    
    This is executed before pytest_runtest_call. 
    pytest_runtest_call is invoked to execute the test item. So the code in here
    is executed before each test.
    """

    if 'slow' in item.keywords and not item.config.getoption('--runslow'
            ):
        pytest.skip('need --runslow option to run')

    # set random seed:
    # Let's not print anything - it clearly works, its just extra output
    # print "Seed C++, python, numpy random number generator to 1"

    rand.seed(1)
Example #2
0
def test_set_seed():
    """
    test set_seed to 1 works
    """

    seed(1)

    xi = [random.uniform(0, i + 1) for i in range(10)]
    ai = np.random.uniform(0, 1, 10)
    ci = [rand() for i in range(10)]

    seed(1)
    xf = [random.uniform(0, i + 1) for i in range(10)]
    af = np.random.uniform(0, 1, 10)
    cf = [rand() for i in range(10)]

    assert xi == xf
    assert np.all(ai == af)
    assert ci == cf
Example #3
0
def test_set_seed():
    """
    test set_seed to 1 works
    """

    seed(1)

    xi = [random.uniform(0, i + 1) for i in range(10)]
    ai = np.random.uniform(0, 1, 10)
    ci = [rand() for i in range(10)]

    seed(1)
    xf = [random.uniform(0, i + 1) for i in range(10)]
    af = np.random.uniform(0, 1, 10)
    cf = [rand() for i in range(10)]

    assert xi == xf
    assert np.all(ai == af)
    assert ci == cf
Example #4
0
def pytest_runtest_setup(item):
    '''
    pytest builtin hook

    This is executed before pytest_runtest_call.
    pytest_runtest_call is invoked to execute the test item.
    So the code in here is executed before each test.
    '''
    if ('slow' in item.keywords and
            not item.config.getoption('--runslow')):
        pytest.skip('need --runslow option to run')

    if (item.config.getoption('--serial') and
            'serial' not in item.keywords):
        pytest.skip('only run tests marked as serial')

    # set random seed:
    # Let's not print anything - it clearly works, its just extra output
    # print "Seed C++, python, numpy random number generator to 1"
    rand.seed(1)