Skip to content

Commit 49c21b7

Browse files
author
Sylvain MARIE
committed
Fixed KeyError issue happening when a fixture is not found. Now users will see the "normal" error message from pytest ("fixture <name> not found"). Fixed #67
1 parent b31facf commit 49c21b7

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pytest_cases/plugin.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,11 @@ def _cleanup_calls_list(self, fix_closure_tree, calls, nodes, pending):
802802
# for fixture in list(fix_closure_tree):
803803
# for fixture_name, fixdef in self.metafunc._arg2fixturedefs.items():
804804
for fixture_name in fix_closure_tree.get_not_always_used():
805-
fixdef = self.metafunc._arg2fixturedefs[fixture_name]
805+
try:
806+
fixdef = self.metafunc._arg2fixturedefs[fixture_name]
807+
except KeyError:
808+
continue # dont raise any error here and let pytest say "not found"
809+
806810
if fixture_name not in c.params and fixture_name not in c.funcargs:
807811
if not n.requires(fixture_name):
808812
# explicitly add it as discarded by creating a parameter value for it.

0 commit comments

Comments
 (0)