Skip to content

Commit e33277f

Browse files
committed
Rename parametrized fixture to 'candindate' from 'wish'.
1 parent aa78eba commit e33277f

File tree

4 files changed

+23
-24
lines changed

4 files changed

+23
-24
lines changed

CHANGELOG.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
0.9.8 (unreleased)
33
------------------
44

5-
- Add the `pytest.mark.target` marker in the place of `pytest_nodev.search`.
5+
- Add the ``pytest.mark.target`` marker in the place of ``pytest_nodev.search``.
66
Issue `#28 <https://github.com/nodev-io/pytest-nodev/issues/28>`_.
7+
- Rename main fixture to ``candidate`` from ``wish``.
78

89

910
0.9.7 (2016-03-13)

pytest_nodev/plugin.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939

4040
def pytest_addoption(parser):
41-
group = parser.getgroup('wish')
41+
group = parser.getgroup('nodev')
4242
group.addoption(
4343
'--wish-from-stdlib', action='store_true',
4444
help="Collects objects form the Python standard library.")
@@ -66,11 +66,11 @@ def pytest_addoption(parser):
6666
group.addoption('--wish-fail', action='store_true', help="Show wish failures.")
6767

6868

69-
def make_wish_index(config):
69+
def make_candidate_index(config):
7070
if config.getoption('wish_from_all') and os.environ.get('PYTEST_NODEV_MODE') != 'FEARLESS':
7171
raise ValueError("Use of --wish-from-all may be very dangerous, see the docs.")
7272

73-
if not hasattr(config, '_wish_index_items'):
73+
if not hasattr(config, '_candicate_index'):
7474
# take over collect logging
7575
collect.logger.propagate = False
7676
collect.logger.setLevel(logging.DEBUG) # FIXME: loglevel should be configurable
@@ -109,40 +109,40 @@ def make_wish_index(config):
109109
)
110110

111111
# store index
112-
config._wish_index_items = list(zip(*sorted(object_index.items()))) or [(), ()]
112+
config._candicate_index = list(zip(*sorted(object_index.items()))) or [(), ()]
113113

114-
return config._wish_index_items
114+
return config._candicate_index
115115

116116

117117
def pytest_pycollect_makeitem(collector, name, obj):
118118
target_marker = getattr(obj, 'target', None)
119119
if target_marker and getattr(target_marker, 'args', []):
120120
target_name = target_marker.args[0]
121121

122-
def wrapper(wish, monkeypatch, *args, **kwargs):
122+
def wrapper(candidate, monkeypatch, *args, **kwargs):
123123
if '.' in target_name:
124-
monkeypatch.setattr(target_name, wish, raising=False)
124+
monkeypatch.setattr(target_name, candidate, raising=False)
125125
else:
126-
monkeypatch.setattr(inspect.getmodule(obj), target_name, wish, raising=False)
126+
monkeypatch.setattr(inspect.getmodule(obj), target_name, candidate, raising=False)
127127
return obj(*args, **kwargs)
128128

129129
wrapper.__dict__ = obj.__dict__
130130
return list(collector._genfunctions(name, wrapper))
131131

132132

133133
def pytest_generate_tests(metafunc):
134-
if 'wish' not in metafunc.fixturenames:
134+
if 'candidate' not in metafunc.fixturenames:
135135
return
136136

137-
ids, params = make_wish_index(metafunc.config)
138-
metafunc.parametrize('wish', params, ids=ids, scope='module')
137+
ids, params = make_candidate_index(metafunc.config)
138+
metafunc.parametrize('candidate', params, ids=ids, scope='module')
139139

140140
if not metafunc.config.getoption('wish_fail'):
141141
metafunc.function = pytest.mark.xfail(metafunc.function)
142142

143143

144144
def pytest_terminal_summary(terminalreporter):
145-
if not hasattr(terminalreporter.config, '_wish_index_items'):
145+
if not hasattr(terminalreporter.config, '_candicate_index'):
146146
return
147147

148148
hit_state = 'passed' if terminalreporter.config.getoption('wish_fail') else 'xpassed'

specs/test_object_from_name.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
import os
22

3-
import pytest
43

5-
6-
def test_object_from_name_simple(wish):
7-
object_from_name = wish
4+
def test_object_from_name_simple(candidate):
5+
object_from_name = candidate
86
assert object_from_name('os:O_CREAT') is os.O_CREAT
97
assert object_from_name('os.path:join') is os.path.join
108
assert object_from_name('builtins:True') is True
119
assert object_from_name('builtins:open') is open
1210

1311

14-
def test_object_from_name_pep3155(wish):
15-
object_from_name = wish
12+
def test_object_from_name_pep3155(candidate):
13+
object_from_name = candidate
1614
# instance methods compare by equality, see http://stackoverflow.com/questions/15977808
1715
assert object_from_name('os:O_CREAT.bit_length') == os.O_CREAT.bit_length
1816
assert object_from_name('builtins:int.bit_length') is int.bit_length

tests/test_plugin.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ def test_pass():
1515
assert True
1616
'''
1717
TEST_FACTORIAL_PY = '''
18-
def test_factorial(wish):
19-
factorial = wish
18+
def test_factorial(candidate):
19+
factorial = candidate
2020
assert factorial(0) == 1
2121
assert factorial(1) == 1
2222
assert factorial(21) == 51090942171709440000
@@ -45,7 +45,7 @@ def test_pytest_addoption(testdir):
4545
)
4646
# fnmatch_lines does an assertion internally
4747
result.stdout.fnmatch_lines([
48-
'wish:',
48+
'nodev:',
4949
'*--wish-from-stdlib*',
5050
'*--wish-fail*',
5151
])
@@ -111,13 +111,13 @@ def test_pytest_run_no_wish(testdir):
111111

112112

113113
def test_pytest_run_no_wish_option(testdir):
114-
"""Skip tests with the *wish* fixture if no ``--wish-*`` option is given."""
114+
"""Skip tests with the *candidate* fixture if no ``--wish-*`` option is given."""
115115
testdir.makepyfile(TEST_FACTORIAL_PY)
116116
result = testdir.runpytest(
117117
'-v',
118118
)
119119
result.stdout.fnmatch_lines([
120-
'*test_factorial*wish*SKIPPED',
120+
'*test_factorial*candidate*SKIPPED',
121121
])
122122
assert result.ret == 0
123123

0 commit comments

Comments
 (0)