File: genty_repeat.py

package info (click to toggle)
python-genty 1.3.2-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 212 kB
  • sloc: python: 1,072; makefile: 3
file content (36 lines) | stat: -rw-r--r-- 927 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# coding: utf-8

from __future__ import unicode_literals


def genty_repeat(count):
    """
    To use in conjunction with a TestClass wrapped with @genty.

    Runs the wrapped test 'count' times:
        @genty_repeat(count)
        def test_some_function(self)
            ...

    Can also wrap a test already decorated with @genty_dataset
        @genty_repeat(3)
        @genty_dataset(True, False)
        def test_some__other_function(self, bool_value):
            ...
    This will run 6 tests in total, 3 each of the True and False cases.

    :param count:
        The number of times to run the test.
    :type count:
        `int`
    """
    if count < 0:
        raise ValueError(
            "Really? Can't have {0} iterations. Please pick a value >= 0."
            .format(count)
        )

    def wrap(test_method):
        test_method.genty_repeat_count = count
        return test_method
    return wrap