Skip to content

Commit b7442e1

Browse files
committed
Remove a namespace conflict that restricted parametrize names
Prior to this the arguments that were given to test functions were limited by other arguments used when passing them around. This is fixed by the use of the syntax introduced in PEP 570 to ensure those arguments specific to the plugin are positional only Fixes #17
1 parent b7232d7 commit b7442e1

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

README.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ generator fixtures.
2121
Changelog
2222
---------
2323

24+
0.8.1 - TBD
25+
* Remove a namespace conflict that restricted what names could be used as
26+
parametrize arguments.
27+
2428
0.8.0 - 1 June 2024
2529
* Provide simple support for tests being aware of asyncio.Context
2630
* Remove support for python less than 3.11

alt_pytest_asyncio/async_converters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def run_fixture(*args, **kwargs):
8686
fixturedef.func = run_fixture
8787

8888

89-
def converted_async_test(ctx, test_tasks, func, timeout, *args, **kwargs):
89+
def converted_async_test(ctx, test_tasks, func, timeout, /, *args, **kwargs):
9090
"""Used to replace async tests"""
9191
__tracebackhide__ = True
9292

alt_pytest_asyncio/plugin.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,11 @@ def pytest_pyfunc_call(self, pyfuncitem):
8989
def run_obj(*args, **kwargs):
9090
try:
9191
self.ctx.run(lambda: None)
92-
run = lambda func, *a, **kw: self.ctx.run(func, *a, **kw)
92+
run = lambda func: self.ctx.run(func)
9393
except RuntimeError:
94-
run = lambda func, *a, **kw: func(*a, **kw)
94+
run = lambda func: func()
9595

96-
run(original, *args, **kwargs)
96+
run(partial(original, *args, **kwargs))
9797

9898
pyfuncitem.obj = run_obj
9999

tests/test_works.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,13 @@ async def a_list(a_list_fut):
5353

5454
it "uses our fixtures", a_value_times_two:
5555
assert a_value_times_two == 2
56+
57+
58+
@pytest.mark.parametrize("func", [1])
59+
it "allows func as a parametrize", func:
60+
assert func == 1
61+
62+
63+
@pytest.mark.parametrize("func", [1])
64+
async it "allows func as a parametrize for async too", func:
65+
assert func == 1

0 commit comments

Comments
 (0)