예제 #1
0
def test_procedure_wrapper():
    assert RandomProcedure.iterations.value == 100
    procedure = RandomProcedure()
    procedure.iterations = 101
    wrapper = ProcedureWrapper(procedure)

    new_wrapper = pickle.loads(pickle.dumps(wrapper))
    assert hasattr(new_wrapper, 'procedure')
    assert new_wrapper.procedure.iterations == 101
    assert RandomProcedure.iterations.value == 100
예제 #2
0
def test_procedure_wrapper():
    assert RandomProcedure.iterations.value == 100
    procedure = RandomProcedure()
    procedure.iterations = 101
    wrapper = ProcedureWrapper(procedure)

    new_wrapper = pickle.loads(pickle.dumps(wrapper))
    assert hasattr(new_wrapper, 'procedure')
    assert new_wrapper.procedure.iterations == 101
    assert RandomProcedure.iterations.value == 100
예제 #3
0
def test_procedure_wrapper():
    assert RandomProcedure.iterations.value == 100
    procedure = RandomProcedure()
    procedure.iterations = 101
    file = tempfile.mktemp()
    results = Results(procedure, file)

    new_results = pickle.loads(pickle.dumps(results))
    assert hasattr(new_results, 'procedure')
    assert new_results.procedure.iterations == 101
    assert RandomProcedure.iterations.value == 100
예제 #4
0
def test_procedure_wrapper():
    assert RandomProcedure.iterations.value == 100
    procedure = RandomProcedure()
    procedure.iterations = 101
    file = tempfile.mktemp()
    results = Results(procedure, file)

    new_results = pickle.loads(pickle.dumps(results))
    assert hasattr(new_results, 'procedure')
    assert new_results.procedure.iterations == 101
    assert RandomProcedure.iterations.value == 100
예제 #5
0
def test_worker_closes_file_after_finishing():
    procedure = RandomProcedure()
    procedure.iterations = 100
    procedure.delay = 0.001
    file = tempfile.mktemp()
    results = Results(procedure, file)
    worker = Worker(results)
    worker.start()
    worker.join(timeout=20.0)

    # Test if the file has been properly closed by removing the file
    os.remove(file)
예제 #6
0
def test_worker_finish():
    procedure = RandomProcedure()
    procedure.iterations = 100
    procedure.delay = 0.001
    file = tempfile.mktemp()
    results = Results(procedure, file)
    worker = Worker(results)
    worker.start()
    worker.join(timeout=20.0)

    assert not worker.is_alive()

    new_results = Results.load(file, procedure_class=RandomProcedure)
    assert new_results.data.shape == (100, 2)