Merge branch 'master' into staging
[jackhill/guix/guix.git] / gnu / packages / python-check.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2019 Ricardo Wurmus <rekado@elephly.net>
3 ;;; Copyright © 2019 Tobias Geerinckx-Rice <me@tobias.gr>
4 ;;; Copyright © 2019, 2020 Efraim Flashner <efraim@flashner.co.il>
5 ;;; Copyright © 2019 Maxim Cournoyer <maxim.cournoyer@gmail.com>
6 ;;; Copyright © 2019 Hartmut Goebel <h.goebel@crazy-compilers.com>
7 ;;; Copyright © 2020 Julien Lepiller <julien@lepiller.eu>
8 ;;; Copyright © 2020 Marius Bakke <mbakke@fastmail.com>
9 ;;; Copyright © 2020 Edouard Klein <edk@beaver-labs.com>
10 ;;;
11 ;;; This file is part of GNU Guix.
12 ;;;
13 ;;; GNU Guix is free software; you can redistribute it and/or modify it
14 ;;; under the terms of the GNU General Public License as published by
15 ;;; the Free Software Foundation; either version 3 of the License, or (at
16 ;;; your option) any later version.
17 ;;;
18 ;;; GNU Guix is distributed in the hope that it will be useful, but
19 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;;; GNU General Public License for more details.
22 ;;;
23 ;;; You should have received a copy of the GNU General Public License
24 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
25
26 (define-module (gnu packages python-check)
27 #:use-module (gnu packages)
28 #:use-module (gnu packages check)
29 #:use-module (gnu packages python-web)
30 #:use-module (gnu packages python-xyz)
31 #:use-module (gnu packages web)
32 #:use-module (guix utils)
33 #:use-module ((guix licenses) #:prefix license:)
34 #:use-module (guix packages)
35 #:use-module (guix git-download)
36 #:use-module (guix download)
37 #:use-module (guix build-system python))
38
39 (define-public python-coveralls
40 (package
41 (name "python-coveralls")
42 (version "1.11.1")
43 (home-page "https://github.com/coveralls-clients/coveralls-python")
44 (source
45 (origin
46 ;; The PyPI release lacks tests, so we pull from git instead.
47 (method git-fetch)
48 (uri (git-reference (url home-page) (commit version)))
49 (file-name (git-file-name name version))
50 (sha256
51 (base32
52 "1zr1lqdjcfwj6wcx2449mzzjq8bbhwnqcm5vdif5s8hlz35bjxkp"))))
53 (build-system python-build-system)
54 (arguments
55 '(#:phases (modify-phases %standard-phases
56 (add-before 'check 'disable-git-test
57 (lambda _
58 ;; Remove test that requires 'git' and the full checkout.
59 (delete-file "tests/git_test.py")
60 #t))
61 (replace 'check
62 (lambda* (#:key tests? #:allow-other-keys)
63 (if tests?
64 (invoke "pytest" "-vv")
65 (format #t "test suite not run~%"))
66 #t)))))
67 (propagated-inputs
68 `(("python-coverage" ,python-coverage)
69 ("python-docopt" ,python-docopt)
70 ("python-pyyaml" ,python-pyyaml)
71 ("python-requests" ,python-requests)))
72 (native-inputs
73 `(("python-mock" ,python-mock)
74 ("python-pytest" ,python-pytest)))
75 (synopsis "Show coverage stats online via coveralls.io")
76 (description
77 "Coveralls.io is a service for publishing code coverage statistics online.
78 This package provides seamless integration with coverage.py (and thus pytest,
79 nosetests, etc...) in Python projects.")
80 (license license:expat)))
81
82 (define-public python-vcrpy
83 (package
84 (name "python-vcrpy")
85 (version "2.0.1")
86 (source
87 (origin
88 (method url-fetch)
89 (uri (pypi-uri "vcrpy" version))
90 (sha256
91 (base32
92 "0kws7l3hci1dvjv01nxw3805q9v2mwldw58bgl8s90wqism69gjp"))))
93 (build-system python-build-system)
94 (arguments `(#:tests? #f)) ; tests require more packages for python-pytest-httpbin
95 (propagated-inputs
96 `(("python-pyyaml" ,python-pyyaml)
97 ("python-six" ,python-six)
98 ("python-wrapt" ,python-wrapt)
99 ("python-yarl" ,python-yarl)))
100 (native-inputs
101 `(("python-mock" ,python-mock)
102 ("python-pytest" ,python-pytest)
103 ("python-pytest-httpbin" ,python-pytest-httpbin)))
104 (home-page "https://github.com/kevin1024/vcrpy")
105 (synopsis "Automatically mock your HTTP interactions")
106 (description
107 "VCR.py simplifies and speeds up tests that make HTTP requests. The first
108 time you run code that is inside a VCR.py context manager or decorated function,
109 VCR.py records all HTTP interactions that take place through the libraries it
110 supports and serializes and writes them to a flat file (in yaml format by
111 default). This flat file is called a cassette. When the relevant piece of code
112 is executed again, VCR.py will read the serialized requests and responses from
113 the aforementioned cassette file, and intercept any HTTP requests that it
114 recognizes from the original test run and return the responses that corresponded
115 to those requests. This means that the requests will not actually result in
116 HTTP traffic, which confers several benefits including:
117 @enumerate
118 @item The ability to work offline
119 @item Completely deterministic tests
120 @item Increased test execution speed
121 @end enumerate
122 If the server you are testing against ever changes its API, all you need to do
123 is delete your existing cassette files, and run your tests again. VCR.py will
124 detect the absence of a cassette file and once again record all HTTP
125 interactions, which will update them to correspond to the new API.")
126 (license license:expat)))
127
128 (define-public python-pytest-vcr
129 (package
130 (name "python-pytest-vcr")
131 (version "1.0.2")
132 (source
133 (origin
134 (method git-fetch)
135 (uri (git-reference
136 (url "https://github.com/ktosiek/pytest-vcr")
137 (commit version)))
138 (file-name (git-file-name name version))
139 (sha256
140 (base32
141 "1i6fin91mklvbi8jzfiswvwf1m91f43smpj36a17xrzk4gisfs6i"))))
142 (build-system python-build-system)
143 (arguments
144 `(#:phases
145 (modify-phases %standard-phases
146 (replace 'check
147 (lambda* (#:key inputs outputs #:allow-other-keys)
148 (add-installed-pythonpath inputs outputs)
149 (invoke "pytest" "tests/"))))))
150 (propagated-inputs
151 `(("python-pytest" ,python-pytest)
152 ("python-vcrpy" ,python-vcrpy)))
153 (home-page "https://github.com/ktosiek/pytest-vcr")
154 (synopsis "Plugin for managing VCR.py cassettes")
155 (description
156 "Plugin for managing VCR.py cassettes.")
157 (license license:expat)))
158
159 (define-public python-pytest-checkdocs
160 (package
161 (name "python-pytest-checkdocs")
162 (version "1.2.2")
163 (source
164 (origin
165 (method url-fetch)
166 (uri (pypi-uri "pytest-checkdocs" version))
167 (sha256
168 (base32 "0j6j1gvj6x451y3qsx4xbaq9p1w9gg3mwk7n0w80cy8vdyjkngb0"))))
169 (build-system python-build-system)
170 (propagated-inputs
171 `(("python-docutils" ,python-docutils)
172 ("python-importlib-metadata" ,python-importlib-metadata)
173 ("python-more-itertools" ,python-more-itertools)))
174 (native-inputs
175 `(("python-setuptools-scm" ,python-setuptools-scm)))
176 (home-page "https://github.com/jaraco/pytest-checkdocs")
177 (synopsis "Check the README when running tests")
178 (description
179 "This package provides a pytest plugin that checks the long description
180 of the project to ensure it renders properly.")
181 (license license:expat)))
182
183 (define-public python-pytest-flake8
184 (package
185 (name "python-pytest-flake8")
186 (version "1.0.4")
187 (source
188 (origin
189 (method url-fetch)
190 (uri (pypi-uri "pytest-flake8" version))
191 (sha256
192 (base32
193 "1h30gd21fjsafqxwclf25sdh89vrdz7rsh4lzw11aiw7ww9mq8jd"))))
194 (build-system python-build-system)
195 (propagated-inputs
196 `(("python-flake8" ,python-flake8)))
197 (native-inputs
198 `(("python-pytest" ,python-pytest)))
199 (home-page "https://github.com/tholo/pytest-flake8")
200 (synopsis "Pytest plugin to check FLAKE8 requirements")
201 (description
202 "This package provides a pytest plugin for efficiently checking PEP8
203 compliance.")
204 (license license:bsd-3)))
205
206 (define-public python-pytest-isort
207 (package
208 (name "python-pytest-isort")
209 (version "0.3.1")
210 (source
211 (origin
212 (method url-fetch)
213 (uri (pypi-uri "pytest-isort" version))
214 (sha256
215 (base32 "06myn5hhxs5yp8dqr1yjsgcnnxnsrvsqannm00bvaw0qml6ydzjb"))))
216 (build-system python-build-system)
217 (arguments
218 `(#:phases
219 (modify-phases %standard-phases
220 (replace 'check
221 (lambda _
222 (setenv "PYTHONPATH"
223 (string-append (getcwd) ":"
224 (getenv "PYTHONPATH")))
225 (invoke "pytest"))))))
226 (propagated-inputs
227 `(("python-isort" ,python-isort)
228 ("python-pytest" ,python-pytest)))
229 (home-page "https://github.com/moccu/pytest-isort/")
230 (synopsis "Pytest plugin to check import ordering using isort")
231 (description
232 "This package provides a pytest plugin to check import ordering using
233 isort.")
234 (license license:bsd-3)))
235
236 (define-public python-pytest-shutil
237 (package
238 (name "python-pytest-shutil")
239 (version "1.7.0")
240 (source
241 (origin
242 (method url-fetch)
243 (uri (pypi-uri "pytest-shutil" version))
244 (sha256
245 (base32
246 "0q8j0ayzmnvlraml6i977ybdq4xi096djhf30n2m1rvnvrhm45nq"))))
247 (build-system python-build-system)
248 (arguments
249 `(#:phases
250 (modify-phases %standard-phases
251 (add-after 'unpack 'patch-tests
252 (lambda _
253 (mkdir "/tmp/bin")
254 (substitute* "tests/integration/test_cmdline_integration.py"
255 (("dirname = '/bin'")
256 "dirname = '/tmp/bin'")
257 (("bindir = os.path.realpath\\('/bin'\\)")
258 "bindir = os.path.realpath('/tmp/bin')"))
259 #t)))))
260 (propagated-inputs
261 `(("python-contextlib2" ,python-contextlib2)
262 ("python-execnet" ,python-execnet)
263 ("python-pathpy" ,python-pathpy)
264 ("python-termcolor" ,python-termcolor)))
265 (native-inputs
266 `(("python-mock" ,python-mock)
267 ("python-pytest" ,python-pytest)
268 ("python-setuptools-git" ,python-setuptools-git)))
269 (home-page "https://github.com/manahl/pytest-plugins")
270 (synopsis "Assorted shell and environment tools for py.test")
271 (description
272 "This package provides assorted shell and environment tools for the
273 py.test testing framework.")
274 (license license:expat)))
275
276 (define-public python-pytest-fixture-config
277 (package
278 (name "python-pytest-fixture-config")
279 (version "1.7.0")
280 (source
281 (origin
282 (method url-fetch)
283 (uri (pypi-uri "pytest-fixture-config" version))
284 (sha256
285 (base32
286 "13i1qpz22w3x4dmw8vih5jdnbqfqvl7jiqs0dg764s0zf8bp98a1"))))
287 (build-system python-build-system)
288 (native-inputs
289 `(("python-pytest" ,python-pytest)
290 ("python-setuptools-git" ,python-setuptools-git)))
291 (home-page "https://github.com/manahl/pytest-plugins")
292 (synopsis "Fixture configuration utils for py.test")
293 (description
294 "This package provides fixture configuration utilities for the py.test
295 testing framework.")
296 (license license:expat)))
297
298 (define-public python-pytest-virtualenv
299 (package
300 (name "python-pytest-virtualenv")
301 (version "1.7.0")
302 (source
303 (origin
304 (method url-fetch)
305 (uri (pypi-uri "pytest-virtualenv" version))
306 (sha256
307 (base32
308 "03w2zz3crblj1p6i8nq17946hbn3zqp9z7cfnifw47hi4a4fww12"))))
309 (build-system python-build-system)
310 (arguments
311 `(#:phases
312 (modify-phases %standard-phases
313 ;; Reference the virtualenv executable directly, to avoid the need
314 ;; for PYTHONPATH, which gets cleared when instantiating a new
315 ;; virtualenv with pytest-virtualenv.
316 (add-after 'unpack 'patch-virtualenv-executable
317 (lambda* (#:key inputs #:allow-other-keys)
318 (let* ((virtualenv (assoc-ref inputs "python-virtualenv"))
319 (virtualenv-bin (string-append virtualenv
320 "/bin/virtualenv")))
321 (substitute* "pytest_virtualenv.py"
322 (("^DEFAULT_VIRTUALENV_FIXTURE_EXECUTABLE.*$")
323 (format #f "DEFAULT_VIRTUALENV_FIXTURE_EXECUTABLE = '~a'"
324 virtualenv-bin)))
325 #t))))))
326 (propagated-inputs
327 `(("python-pytest-shutil" ,python-pytest-shutil)
328 ("python-pytest-fixture-config" ,python-pytest-fixture-config)))
329 (inputs
330 `(("python-virtualenv" ,python-virtualenv)))
331 (native-inputs
332 `(("python-mock" ,python-mock)
333 ("python-pytest" ,python-pytest)
334 ("python-setuptools-git" ,python-setuptools-git)))
335 (home-page "https://github.com/manahl/pytest-plugins")
336 (synopsis "Virtualenv fixture for py.test")
337 (description "This package provides a virtualenv fixture for the py.test
338 framework.")
339 (license license:expat)))
340
341 (define-public python-pytest-pycodestyle
342 (package
343 (name "python-pytest-pycodestyle")
344 (version "2.0.0") ;later versions require python-pytest~=5.4
345 (source
346 (origin
347 (method url-fetch)
348 (uri (pypi-uri "pytest-pycodestyle" version))
349 (sha256
350 (base32
351 "02i5gl7pm9cwxk15sn29inz3n8flpj1r3p1l110h43f2na5w8h7z"))))
352 (build-system python-build-system)
353 (propagated-inputs
354 `(("python-pycodestyle" ,python-pycodestyle)))
355 (native-inputs
356 `(("python-pytest" ,python-pytest)))
357 (home-page "https://github.com/henry0312/pytest-pycodestyle")
358 (synopsis "Pytest plugin to run pycodestyle")
359 (description "This package provides a plugin to run @code{pycodestyle}
360 for the @code{pytest} framework.")
361 (license license:expat)))
362
363 (define-public python-codacy-coverage
364 (package
365 (name "python-codacy-coverage")
366 (version "1.3.11")
367 (source
368 (origin
369 (method url-fetch)
370 (uri (pypi-uri "codacy-coverage" version))
371 (sha256
372 (base32
373 "1g0c0w56xdkmqb8slacyw5qhzrkp814ng3ddh2lkiij58y9m2imr"))))
374 (build-system python-build-system)
375 (arguments
376 `(#:tests? #f)); no tests
377 (propagated-inputs
378 `(("python-check-manifest" ,python-check-manifest)))
379 (home-page "https://github.com/codacy/python-codacy-coverage")
380 (synopsis "Codacy coverage reporter for Python")
381 (description "This package analyses Python test suites and reports how much
382 of the code is covered by them. This tool is part of the Codacy suite for
383 analysing code quality.")
384 (license license:expat)))
385
386 (define-public python-httmock
387 (package
388 (name "python-httmock")
389 (version "1.3.0")
390 (source
391 (origin
392 (method url-fetch)
393 (uri (pypi-uri "httmock" version))
394 (sha256
395 (base32
396 "1zj1fcm0n6f0wr9mr0hmlqz9430fnr5cdwd5jkcvq9j44bnsrfz0"))))
397 (build-system python-build-system)
398 (arguments
399 `(#:tests? #f)); no tests
400 (propagated-inputs
401 `(("python-requests" ,python-requests)))
402 (home-page "https://github.com/patrys/httmock")
403 (synopsis "Mocking library for requests.")
404 (description "This package provides a library for replying fake data to
405 Python software under test, when they make an HTTP query.")
406 (license license:asl2.0)))