diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index faf626d..470da2f 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -12,16 +12,16 @@ on: jobs: build: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 timeout-minutes: 5 strategy: matrix: - python-version: [2.7, 3.6, 3.7, 3.8, 3.9, '3.10'] + python-version: [3.6, 3.7, 3.8, 3.9, '3.10'] steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v1 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - name: Install dependencies diff --git a/ddt.py b/ddt.py index 19e1244..9eb6440 100644 --- a/ddt.py +++ b/ddt.py @@ -215,9 +215,15 @@ def feed_data(func, new_name, test_data_docstring, *args, **kwargs): This internal method decorator feeds the test data item to the test. """ - @wraps(func) - def wrapper(self): - return func(self, *args, **kwargs) + if inspect.iscoroutinefunction(func): + @wraps(func) + async def wrapper(self): + return await func(self, *args, **kwargs) + else: + @wraps(func) + def wrapper(self): + return func(self, *args, **kwargs) + wrapper.__name__ = new_name wrapper.__wrapped__ = func # set docstring if exists diff --git a/requirements/test.txt b/requirements/test.txt index b07910e..de272ad 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -1,3 +1,4 @@ +aiounittest codecov coverage flake8 diff --git a/test/test_async.py b/test/test_async.py new file mode 100644 index 0000000..dbd312f --- /dev/null +++ b/test/test_async.py @@ -0,0 +1,11 @@ +import aiounittest + +from ddt import ddt, data +from test.mycode import larger_than_two + + +@ddt +class TestAsync(aiounittest.AsyncTestCase): + @data(3, 4, 12, 23) + async def test_larger_than_two(self, value): + self.assertTrue(larger_than_two(value)) diff --git a/tox.ini b/tox.ini index a5115b4..9c1ddef 100644 --- a/tox.ini +++ b/tox.ini @@ -6,6 +6,7 @@ deps = pytest pytest-cov coverage + aiounittest flake8 six>=1.4.0 PyYAML