diff --git a/pandas/tests/indexing/test_coercion.py b/pandas/tests/indexing/test_coercion.py index d37b5986b57c1..436b2aa838b08 100644 --- a/pandas/tests/indexing/test_coercion.py +++ b/pandas/tests/indexing/test_coercion.py @@ -29,11 +29,21 @@ def has_test(combo): klass in x.name and dtype in x.name and method in x.name for x in cls_funcs ) - for combo in combos: - if not has_test(combo): - raise AssertionError(f"test method is not defined: {cls.__name__}, {combo}") + opts = request.config.option + if opts.lf or opts.keyword: + # If we are running with "last-failed" or -k foo, we expect to only + # run a subset of tests. + yield - yield + else: + + for combo in combos: + if not has_test(combo): + raise AssertionError( + f"test method is not defined: {cls.__name__}, {combo}" + ) + + yield class CoercionBase: