Exemplo n.º 1
0
def test_TestSequence_setup():
    """ Ensures that the "setup" function is called when specified. """
    def setup_function():
        with open('test_data.txt', 'w') as f:
            f.write('data')

    ts = mats.TestSequence(sequence=[t1, t2], setup=setup_function)
    ts.start()
    while ts.in_progress is True:
        sleep(0.1)

    assert path.exists('test_data.txt')
    remove('test_data.txt')
Exemplo n.º 2
0
def test_TestSequence_run_with_callback():
    """
    Testing to ensure that the callback is executed during a normal test \
    sequence.

    :param normal_test_sequence:
    :return:
    """
    count = 0

    def increment_count(data):
        nonlocal count
        count += 1

    ts = mats.TestSequence(sequence=[t1, t2], callback=increment_count)
    ts.start()

    while (ts.in_progress):
        sleep(0.1)

    assert count == 1
Exemplo n.º 3
0
def test_TestSequence_run():
    """
    Checking a normal test sequence.

    :param normal_test_sequence:
    :return:
    """
    ts = mats.TestSequence(sequence=[t1, t2])

    assert ts.ready
    ts.start()

    # wait a small amount of time, ensure that the test sequence has
    # begun and is in progress
    sleep(0.1)
    assert ts.in_progress is True

    while ts.in_progress is True:
        sleep(0.1)

    assert ts.in_progress is False
Exemplo n.º 4
0
def test_TestSequence_teardown_exception():
    """
    Tests the case in which there is some exception that occurs during \
    the teardown phase of the test.  THe test should execute the teardown \
    sequence.

    :return: None
    """
    counter = 0

    def on_test_exception():
        nonlocal counter
        counter += 1

    ts = mats.TestSequence(sequence=[T_teardown_exception()],
                           teardown=on_test_exception)
    ts.start()

    while ts.in_progress is True:
        sleep(0.1)

    assert counter == 1
Exemplo n.º 5
0
def test_TestSequence_run_attempted_interrupt():
    """
    Testing to ensure that an interrupted test sequence is not actually \
    interrupted.  This test should clearly show in the coverage and in the \
    logging messages.

    :return:
    """
    ts = mats.TestSequence(sequence=[t1, t2])

    assert ts.ready
    ts.start()

    # wait a small amount of time, ensure that the test sequence has
    # begun and is in progress
    sleep(0.1)
    assert ts.in_progress is True
    ts.start()

    while ts.in_progress is True:
        sleep(0.1)

    assert ts.in_progress is False
Exemplo n.º 6
0
def aborted_test_sequence():
    global test_counter
    yield mats.TestSequence(sequence=[ta])
    test_counter = 0
Exemplo n.º 7
0
def normal_test_sequence():
    global test_counter
    yield mats.TestSequence(sequence=[t1, t2])
    test_counter = 0
Exemplo n.º 8
0
def test_TestSequence_empty_raises_TE():
    ts = mats.TestSequence(sequence=[T_normal_1, T_normal_2])
    with pytest.raises(KeyError):
        ts['test 3']
Exemplo n.º 9
0
def test_TestSequence_uninstantiated_Tests():
    mats.TestSequence(sequence=[T_normal_1, T_normal_2])
Exemplo n.º 10
0
def test_TestSequence_duplicate_monikers():
    with pytest.raises(ValueError):
        mats.TestSequence(sequence=[t1, t1, t1])
Exemplo n.º 11
0
def auto_run_test_sequence():
    global test_counter
    yield mats.TestSequence(sequence=[t1, t2], auto_start=True, auto_run=True)
    test_counter = 0
Exemplo n.º 12
0
def failed_test_sequence():
    global test_counter
    yield mats.TestSequence(sequence=[t1, tf])
    test_counter = 0