Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions pytest_cases/common_pytest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
# License: 3-clause BSD, <https://github.com/smarie/python-pytest-cases/blob/master/LICENSE>
from __future__ import division

import sys

from makefun import add_signature_parameters, wraps

try: # python 3.3+
Expand Down Expand Up @@ -537,8 +539,6 @@ def mini_idvalset(argnames, argvalues, idx):
try:
from _pytest.compat import getfuncargnames # noqa
except ImportError:
import sys

def num_mock_patch_args(function):
""" return number of arguments used up by mock arguments (if any) """
patchings = getattr(function, "patchings", None)
Expand Down Expand Up @@ -588,7 +588,9 @@ def __init__(self, nodeid):
class MiniMetafunc(Metafunc):
# noinspection PyMissingConstructor
def __init__(self, func):
self.config = None
from .plugin import PYTEST_CONFIG # late import to ensure config has been loaded by now

self.config = PYTEST_CONFIG
self.function = func
self.definition = MiniFuncDef(func.__name__)
self._calls = []
Expand Down
7 changes: 7 additions & 0 deletions pytest_cases/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1290,14 +1290,21 @@ def pytest_addoption(parser):
)


# will be loaded when the pytest_configure hook below is called
PYTEST_CONFIG = None # type: _pytest.config.Config


# @hookspec(historic=True)
def pytest_configure(config):
global PYTEST_CONFIG
# validate the config
allowed_values = ('normal', 'skip')
reordering_choice = config.getoption(_OPTION_NAME)
if reordering_choice not in allowed_values:
raise ValueError("[pytest-cases] Wrong --%s option: %s. Allowed values: %s"
"" % (_OPTION_NAME, reordering_choice, allowed_values))
# store the received config object for future use; see #165 & #166
PYTEST_CONFIG = config


@pytest.hookimpl(tryfirst=True, hookwrapper=True)
Expand Down
11 changes: 11 additions & 0 deletions pytest_cases/tests/cases/issues/test_issue_165.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import pytest_cases


@pytest_cases.parametrize(x=[])
def case_empty(x):
return x # pragma: no cover


@pytest_cases.parametrize_with_cases("x", case_empty)
def test_empty_parameter_set(x):
assert False # pragma: no cover