1111RE_URLS = re .compile ('<li><a href="[^"]+">[^<]+</a></li>' )
1212
1313
14+ def run (directory , command , * args , ** kwargs ):
15+ """Run command using run_command() function. Supports string and py.path paths.
16+
17+ :param directory: Root git directory and current working directory.
18+ :param iter command: Command to run.
19+ :param iter args: Passed to run_command().
20+ :param dict kwargs: Passed to run_command().
21+
22+ :return: run_command() output.
23+ :rtype: str
24+ """
25+ return run_command (str (directory ), [str (i ) for i in command ], * args , ** kwargs )
26+
27+
28+ def pytest_namespace ():
29+ """Add objects to the pytest namespace. Can be retrieved by importing pytest and accessing pytest.<name>.
30+
31+ :return: Namespace dict.
32+ :rtype: dict
33+ """
34+ return dict (
35+ run = run ,
36+ )
37+
38+
1439@pytest .fixture
1540def config (monkeypatch ):
1641 """Mock config from Click context.
@@ -26,19 +51,13 @@ def config(monkeypatch):
2651 return instance
2752
2853
29- @pytest .fixture
30- def run ():
31- """run_command() wrapper returned from a pytest fixture."""
32- return lambda d , c , * args , ** kwargs : run_command (str (d ), [str (i ) for i in c ], * args , ** kwargs )
33-
34-
3554@pytest .fixture
3655def banner ():
3756 """Verify banner in HTML file match expected."""
3857 def match (path , expected_url = None , expected_base = None ):
3958 """Assert equals and return file contents.
4059
41- :param py.path path: Path to file to read.
60+ :param py.path.local path: Path to file to read.
4261 :param str expected_url: Expected URL in <a href="" /> link.
4362 :param str expected_base: Expected base message.
4463
@@ -61,7 +80,7 @@ def urls():
6180 def match (path , expected ):
6281 """Assert equals and return file contents.
6382
64- :param py.path path: Path to file to read.
83+ :param py.path.local path: Path to file to read.
6584 :param list expected: Expected matches.
6685
6786 :return: File contents.
@@ -75,11 +94,10 @@ def match(path, expected):
7594
7695
7796@pytest .fixture
78- def local_empty (tmpdir , run ):
97+ def local_empty (tmpdir ):
7998 """Local git repository with no commits.
8099
81100 :param tmpdir: pytest fixture.
82- :param run: local fixture.
83101
84102 :return: Path to repo root.
85103 :rtype: py.path
@@ -90,11 +108,10 @@ def local_empty(tmpdir, run):
90108
91109
92110@pytest .fixture
93- def remote (tmpdir , run ):
111+ def remote (tmpdir ):
94112 """Remote git repository with nothing pushed to it.
95113
96114 :param tmpdir: pytest fixture.
97- :param run: local fixture.
98115
99116 :return: Path to bare repo root.
100117 :rtype: py.path
@@ -105,11 +122,10 @@ def remote(tmpdir, run):
105122
106123
107124@pytest .fixture
108- def local_commit (local_empty , run ):
125+ def local_commit (local_empty ):
109126 """Local git repository with one commit.
110127
111128 :param local_empty: local fixture.
112- :param run: local fixture.
113129
114130 :return: Path to repo root.
115131 :rtype: py.path
@@ -121,12 +137,11 @@ def local_commit(local_empty, run):
121137
122138
123139@pytest .fixture
124- def local (local_commit , remote , run ):
140+ def local (local_commit , remote ):
125141 """Local git repository with branches, light tags, and annotated tags pushed to remote.
126142
127143 :param local_commit: local fixture.
128144 :param remote: local fixture.
129- :param run: local fixture.
130145
131146 :return: Path to repo root.
132147 :rtype: py.path
@@ -141,13 +156,12 @@ def local(local_commit, remote, run):
141156
142157
143158@pytest .fixture
144- def local_light (tmpdir , local , remote , run ):
159+ def local_light (tmpdir , local , remote ):
145160 """Light-weight local repository similar to how Travis/AppVeyor clone repos.
146161
147162 :param tmpdir: pytest fixture.
148163 :param local: local fixture.
149164 :param remote: local fixture.
150- :param run: local fixture.
151165
152166 :return: Path to repo root.
153167 :rtype: py.path
@@ -162,13 +176,12 @@ def local_light(tmpdir, local, remote, run):
162176
163177
164178@pytest .fixture
165- def outdate_local (tmpdir , local_light , remote , run ):
179+ def outdate_local (tmpdir , local_light , remote ):
166180 """Clone remote to other directory and push changes. Causes `local` fixture to be outdated.
167181
168182 :param tmpdir: pytest fixture.
169183 :param local_light: local fixture.
170184 :param remote: local fixture.
171- :param run: local fixture.
172185
173186 :return: Path to repo root.
174187 :rtype: py.path
@@ -190,11 +203,10 @@ def outdate_local(tmpdir, local_light, remote, run):
190203
191204
192205@pytest .fixture
193- def local_docs (local , run ):
206+ def local_docs (local ):
194207 """Local repository with Sphinx doc files. Pushed to remote.
195208
196209 :param local: local fixture.
197- :param run: local fixture.
198210
199211 :return: Path to repo root.
200212 :rtype: py.path
@@ -242,11 +254,10 @@ def local_docs(local, run):
242254
243255
244256@pytest .fixture
245- def local_docs_ghp (local_docs , run ):
257+ def local_docs_ghp (local_docs ):
246258 """Add an orphaned branch to remote.
247259
248260 :param local_docs: local fixture.
249- :param run: local fixture.
250261 """
251262 run (local_docs , ['git' , 'checkout' , '--orphan' , 'gh-pages' ])
252263 run (local_docs , ['git' , 'rm' , '-rf' , '.' ])
0 commit comments