1 |
commit: eff6347a4144e8b5a21dfb38702594651835e7ed |
2 |
Author: Patrick McLean <patrick.mclean <AT> sony <DOT> com> |
3 |
AuthorDate: Wed May 6 23:46:28 2020 +0000 |
4 |
Commit: Patrick McLean <chutzpah <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu May 7 00:16:24 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=eff6347a |
7 |
|
8 |
dev-python/snapshottest: New package |
9 |
|
10 |
Copyright: Sony Interactive Entertainment Inc. |
11 |
Package-Manager: Portage-2.3.99, Repoman-2.3.22 |
12 |
Signed-off-by: Patrick McLean <chutzpah <AT> gentoo.org> |
13 |
|
14 |
dev-python/snapshottest/Manifest | 1 + |
15 |
.../files/snapshottest-0.5.1-remove-fastdiff.patch | 57 ++++++++++++++++++++++ |
16 |
dev-python/snapshottest/metadata.xml | 12 +++++ |
17 |
dev-python/snapshottest/snapshottest-0.5.1.ebuild | 49 +++++++++++++++++++ |
18 |
4 files changed, 119 insertions(+) |
19 |
|
20 |
diff --git a/dev-python/snapshottest/Manifest b/dev-python/snapshottest/Manifest |
21 |
new file mode 100644 |
22 |
index 00000000000..8b4c6149861 |
23 |
--- /dev/null |
24 |
+++ b/dev-python/snapshottest/Manifest |
25 |
@@ -0,0 +1 @@ |
26 |
+DIST snapshottest-0.5.1.tar.gz 19312 BLAKE2B a8acfb09de9e58c7a929f71d10f3cc68d7eec31a9fa1ea0fe74ae8a574ceec315f7eab2f9e7cd326c34d981b5ede4c398b5f1352bd59c23be219eeb9a2c0e861 SHA512 1541c327c4238c816b55cf797f6104ad54ff62a2332517b3bf9a455bbee0abd49f6983a54dc7510d1e1c659d88e5f7d6c6aa396c0ece19e19957ea8cff42c673 |
27 |
|
28 |
diff --git a/dev-python/snapshottest/files/snapshottest-0.5.1-remove-fastdiff.patch b/dev-python/snapshottest/files/snapshottest-0.5.1-remove-fastdiff.patch |
29 |
new file mode 100644 |
30 |
index 00000000000..ec12f15fe7a |
31 |
--- /dev/null |
32 |
+++ b/dev-python/snapshottest/files/snapshottest-0.5.1-remove-fastdiff.patch |
33 |
@@ -0,0 +1,57 @@ |
34 |
+From 3e31b54d349eb136f0d96eb81309fdaf4ad35fcf Mon Sep 17 00:00:00 2001 |
35 |
+From: David Shepherd <davidshepherd7@×××××.com> |
36 |
+Date: Sat, 15 Feb 2020 11:48:52 +0000 |
37 |
+Subject: [PATCH] Revert "Use fastdiff for faster diffing" |
38 |
+ |
39 |
+This reverts commit 56d9efdaa37c39c7f644726e0d34c89b09ff9568. |
40 |
+--- |
41 |
+ setup.py | 2 +- |
42 |
+ snapshottest/diff.py | 9 +++++---- |
43 |
+ 2 files changed, 6 insertions(+), 5 deletions(-) |
44 |
+ |
45 |
+diff --git a/setup.py b/setup.py |
46 |
+index 1baefd8..690713e 100644 |
47 |
+--- a/setup.py |
48 |
++++ b/setup.py |
49 |
+@@ -23,7 +23,7 @@ |
50 |
+ 'nose.plugins.0.10': |
51 |
+ ['snapshottest = snapshottest.nose:SnapshotTestPlugin'] |
52 |
+ }, |
53 |
+- install_requires=['six>=1.10.0', 'termcolor', 'fastdiff>=0.1.4<1'], |
54 |
++ install_requires=['six>=1.10.0', 'termcolor'], |
55 |
+ tests_require=tests_require, |
56 |
+ extras_require={ |
57 |
+ 'test': tests_require, |
58 |
+diff --git a/snapshottest/diff.py b/snapshottest/diff.py |
59 |
+index 5fddf66..83c599a 100644 |
60 |
+--- a/snapshottest/diff.py |
61 |
++++ b/snapshottest/diff.py |
62 |
+@@ -1,5 +1,5 @@ |
63 |
++from difflib import Differ |
64 |
+ from termcolor import colored |
65 |
+-from fastdiff import compare |
66 |
+ |
67 |
+ from .sorted_dict import SortedDict |
68 |
+ from .formatter import Formatter |
69 |
+@@ -23,6 +23,7 @@ def format_line(line): |
70 |
+ class PrettyDiff(object): |
71 |
+ def __init__(self, obj, snapshottest): |
72 |
+ self.pretty = Formatter() |
73 |
++ self.differ = Differ() |
74 |
+ self.snapshottest = snapshottest |
75 |
+ if isinstance(obj, dict): |
76 |
+ obj = SortedDict(**obj) |
77 |
+@@ -35,10 +36,10 @@ def __repr__(self): |
78 |
+ return repr(self.obj) |
79 |
+ |
80 |
+ def get_diff(self, other): |
81 |
+- text1 = 'Received \n\n' + self.pretty(self.obj) |
82 |
+- text2 = 'Snapshot \n\n' + self.pretty(other) |
83 |
++ text1 = ['Received ', ''] + self.pretty(self.obj).splitlines(1) |
84 |
++ text2 = ['Snapshot ', ''] + self.pretty(other).splitlines(1) |
85 |
+ |
86 |
+- lines = list(compare(text2, text1)) |
87 |
++ lines = list(self.differ.compare(text2, text1)) |
88 |
+ return [ |
89 |
+ format_line(line) for line in lines |
90 |
+ ] |
91 |
|
92 |
diff --git a/dev-python/snapshottest/metadata.xml b/dev-python/snapshottest/metadata.xml |
93 |
new file mode 100644 |
94 |
index 00000000000..592df77578d |
95 |
--- /dev/null |
96 |
+++ b/dev-python/snapshottest/metadata.xml |
97 |
@@ -0,0 +1,12 @@ |
98 |
+<?xml version="1.0" encoding="UTF-8"?> |
99 |
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd"> |
100 |
+<pkgmetadata> |
101 |
+ <maintainer type="project"> |
102 |
+ <email>python@g.o</email> |
103 |
+ <name>Python</name> |
104 |
+ </maintainer> |
105 |
+ <upstream> |
106 |
+ <remote-id type="pypi">sphinxcontrib-httpdomain</remote-id> |
107 |
+ <remote-id type="bitbucket">birkenfeld/sphinx-contrib</remote-id> |
108 |
+ </upstream> |
109 |
+</pkgmetadata> |
110 |
|
111 |
diff --git a/dev-python/snapshottest/snapshottest-0.5.1.ebuild b/dev-python/snapshottest/snapshottest-0.5.1.ebuild |
112 |
new file mode 100644 |
113 |
index 00000000000..f460c89932a |
114 |
--- /dev/null |
115 |
+++ b/dev-python/snapshottest/snapshottest-0.5.1.ebuild |
116 |
@@ -0,0 +1,49 @@ |
117 |
+# Copyright 2020 Gentoo Authors |
118 |
+# Distributed under the terms of the GNU General Public License v2 |
119 |
+ |
120 |
+EAPI=7 |
121 |
+ |
122 |
+PYTHON_COMPAT=( python3_{6,7,8} ) |
123 |
+DISTUTILS_USE_SETUPTOOLS=rdepend |
124 |
+inherit distutils-r1 |
125 |
+ |
126 |
+# no tests on pypi, no tags on github |
127 |
+COMMIT_HASH="4ac2b4fb09e9e7728bebb11967c164a914775d1d" |
128 |
+ |
129 |
+DESCRIPTION="Snapshot Testing utils for Python" |
130 |
+HOMEPAGE="https://pypi.org/project/snapshottest/ |
131 |
+ https://github.com/syrusakbary/snapshottest" |
132 |
+SRC_URI="https://github.com/syrusakbary/${PN}/archive/${COMMIT_HASH}.tar.gz -> ${P}.tar.gz" |
133 |
+S="${WORKDIR}/${PN}-${COMMIT_HASH}" |
134 |
+ |
135 |
+LICENSE="MIT" |
136 |
+SLOT="0" |
137 |
+KEYWORDS="~amd64 ~x86" |
138 |
+IUSE="test" |
139 |
+RESTRICT="!test? ( test )" |
140 |
+ |
141 |
+RDEPEND=" |
142 |
+ dev-python/six[${PYTHON_USEDEP}] |
143 |
+ dev-python/termcolor[${PYTHON_USEDEP}] |
144 |
+" |
145 |
+BDEPEND="${RDEPEND} |
146 |
+ test? ( |
147 |
+ dev-python/pytest[${PYTHON_USEDEP}] |
148 |
+ ) |
149 |
+" |
150 |
+ |
151 |
+PATCHES=( |
152 |
+ "${FILESDIR}/snapshottest-0.5.1-remove-fastdiff.patch" |
153 |
+) |
154 |
+ |
155 |
+python_prepare_all() { |
156 |
+ sed -e "s:'pytest-runner'(,|)::" -i setup.py || die |
157 |
+ sed -r -e 's:--cov[[:space:]]*[[:graph:]]+::g' -i setup.cfg || die |
158 |
+ distutils-r1_python_prepare_all |
159 |
+} |
160 |
+ |
161 |
+python_test() { |
162 |
+ distutils_install_for_testing |
163 |
+ pytest -vv tests examples/pytest || die "Tests failed with ${EPYTHON}" |
164 |
+ "${EPYTHON}" examples/unittest/test_demo.py || die "Tests failed with ${EPYTHON}" |
165 |
+} |