Anybody know how to use pyresttest's 'fixed_sequence' generator?

144 Views Asked by At

I'm trying to use pyresttest's benchmarking framework to generate a sequence of entries in my flask_sqlalchemy-based database. I would like to read input values from a pre-defined list as advertised by this framework's benchmarking generator type 'fixed_sequence', but it's only picking up the first element of the list.

Here is the issue that explains my problem in detail, with an example: https://github.com/svanoort/pyresttest/issues/264

Any pointer in the right direction will be greatly appreciated

1

There are 1 best solutions below

0
naviram On

I looked into the code, it is jsut a bug, this feature was never used by anyone. https://github.com/svanoort/pyresttest/blob/master/pyresttest/generators.py#L100 instead of: ``` def factory_fixed_sequence(values): """ Return a generator that runs through a list of values in order, looping after end """

def seq_generator():
    my_list = list(values)
    i = 0
    while(True):
        yield my_list[i]
        if i == len(my_list):
            i = 0
return seq_generator

It should be: def factory_fixed_sequence(values): """ Return a generator that runs through a list of values in order, looping after end """

def seq_generator():
    my_list = list(values)
    i = 0
    while(True):
        yield my_list[i]
        i += 1
        if i == len(my_list):
            i = 0
return seq_generator

```

The i += 1 is missing