Skip to content

Commit ce9b413

Browse files
author
Sylvain MARIE
committed
Now appending fixtures to the closure once it has been built is supported. This fixes an issue with pytest-asyncio. Fixes #176
1 parent 1afcb59 commit ce9b413

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

pytest_cases/plugin.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ def _build_closure(self,
325325
# ------ tools to add new fixture names during closure construction
326326

327327
def add_required_fixture(self, new_fixture_name, new_fixture_defs):
328-
"""Add some required fixture names to this node. Returns True if new fixtures were added here (not in child)"""
328+
"""Add some required fixture names to all leaves under this node"""
329329
if self.already_knows_fixture(new_fixture_name):
330330
return
331331
elif not self.has_split():
@@ -574,15 +574,17 @@ def __setitem__(self, i, o):
574574
def __delitem__(self, i):
575575
self.remove(self[i])
576576

577-
def insert(self, index, object):
577+
def insert(self, index, fixture_name):
578578
# if index == 0:
579-
# print()
580-
# elif index == len(self):
581-
# print()
582-
# else:
583-
# raise ValueError("It is not possible to insert a fixture name in this closure")
584-
raise NotImplementedError("When fixture unions are present, inserting a fixture in the closure is non-trivial."
585-
" Please report this so that we can find a suitable solution for your need.")
579+
# # prepend
580+
# self.tree.fixture_defs
581+
if index == len(self):
582+
# append: supported
583+
self.tree.build_closure((fixture_name,))
584+
else:
585+
raise NotImplementedError("When fixture unions are present, inserting a fixture in the closure is "
586+
"non-trivial. Please report this so that we can find a suitable solution for "
587+
"your need.")
586588

587589
def remove(self, value):
588590
# try:

0 commit comments

Comments
 (0)