Skip to content
This repository was archived by the owner on Jun 11, 2019. It is now read-only.

Commit 407427d

Browse files
committed
Avoiding shadowing fixture functions.
Using new pytest feature to set fixture names in the decorator. Avoids ugly yellow marks in PyCharm.
1 parent 259324e commit 407427d

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

tests/conftest.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -93,58 +93,58 @@ def match(path, expected):
9393
return match
9494

9595

96-
@pytest.fixture
97-
def local_empty(tmpdir):
96+
@pytest.fixture(name='local_empty')
97+
def fx_local_empty(tmpdir):
9898
"""Local git repository with no commits.
9999
100100
:param tmpdir: pytest fixture.
101101
102102
:return: Path to repo root.
103-
:rtype: py.path
103+
:rtype: py.path.local
104104
"""
105105
repo = tmpdir.ensure_dir('local')
106106
run(repo, ['git', 'init'])
107107
return repo
108108

109109

110-
@pytest.fixture
111-
def remote(tmpdir):
110+
@pytest.fixture(name='remote')
111+
def fx_remote(tmpdir):
112112
"""Remote git repository with nothing pushed to it.
113113
114114
:param tmpdir: pytest fixture.
115115
116116
:return: Path to bare repo root.
117-
:rtype: py.path
117+
:rtype: py.path.local
118118
"""
119119
repo = tmpdir.ensure_dir('remote')
120120
run(repo, ['git', 'init', '--bare'])
121121
return repo
122122

123123

124-
@pytest.fixture
125-
def local_commit(local_empty):
124+
@pytest.fixture(name='local_commit')
125+
def fx_local_commit(local_empty):
126126
"""Local git repository with one commit.
127127
128128
:param local_empty: local fixture.
129129
130130
:return: Path to repo root.
131-
:rtype: py.path
131+
:rtype: py.path.local
132132
"""
133133
local_empty.join('README').write('Dummy readme file.')
134134
run(local_empty, ['git', 'add', 'README'])
135135
run(local_empty, ['git', 'commit', '-m', 'Initial commit.'])
136136
return local_empty
137137

138138

139-
@pytest.fixture
140-
def local(local_commit, remote):
139+
@pytest.fixture(name='local')
140+
def fx_local(local_commit, remote):
141141
"""Local git repository with branches, light tags, and annotated tags pushed to remote.
142142
143143
:param local_commit: local fixture.
144144
:param remote: local fixture.
145145
146146
:return: Path to repo root.
147-
:rtype: py.path
147+
:rtype: py.path.local
148148
"""
149149
run(local_commit, ['git', 'tag', 'light_tag'])
150150
run(local_commit, ['git', 'tag', '--annotate', '-m', 'Tag annotation.', 'annotated_tag'])
@@ -155,16 +155,16 @@ def local(local_commit, remote):
155155
return local_commit
156156

157157

158-
@pytest.fixture
159-
def local_light(tmpdir, local, remote):
158+
@pytest.fixture(name='local_light')
159+
def fx_local_light(tmpdir, local, remote):
160160
"""Light-weight local repository similar to how Travis/AppVeyor clone repos.
161161
162162
:param tmpdir: pytest fixture.
163163
:param local: local fixture.
164164
:param remote: local fixture.
165165
166166
:return: Path to repo root.
167-
:rtype: py.path
167+
:rtype: py.path.local
168168
"""
169169
assert local # Ensures local pushes feature branch before this fixture is called.
170170
local2 = tmpdir.ensure_dir('local2')
@@ -184,7 +184,7 @@ def outdate_local(tmpdir, local_light, remote):
184184
:param remote: local fixture.
185185
186186
:return: Path to repo root.
187-
:rtype: py.path
187+
:rtype: py.path.local
188188
"""
189189
assert local_light # Ensures local_light is setup before this fixture pushes to remote.
190190
local_ahead = tmpdir.ensure_dir('local_ahead')
@@ -202,14 +202,14 @@ def outdate_local(tmpdir, local_light, remote):
202202
return local_ahead
203203

204204

205-
@pytest.fixture
206-
def local_docs(local):
205+
@pytest.fixture(name='local_docs')
206+
def fx_local_docs(local):
207207
"""Local repository with Sphinx doc files. Pushed to remote.
208208
209209
:param local: local fixture.
210210
211211
:return: Path to repo root.
212-
:rtype: py.path
212+
:rtype: py.path.local
213213
"""
214214
local.ensure('conf.py')
215215
local.join('contents.rst').write(

0 commit comments

Comments
 (0)