approval-utilities 11.1.2__tar.gz → 11.2.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of approval-utilities might be problematic. Click here for more details.
- {approval_utilities-11.1.2/approval_utilities.egg-info → approval_utilities-11.2.1}/PKG-INFO +1 -1
- approval_utilities-11.2.1/approval_utilities/utilities/multiline_string_utils.py +13 -0
- {approval_utilities-11.1.2 → approval_utilities-11.2.1/approval_utilities.egg-info}/PKG-INFO +1 -1
- {approval_utilities-11.1.2 → approval_utilities-11.2.1}/tests/test_inline_approvals.py +38 -0
- {approval_utilities-11.1.2 → approval_utilities-11.2.1}/tests/test_multiline_string_utils.py +14 -0
- approval_utilities-11.2.1/tests/test_parse_inputs.py +117 -0
- approval_utilities-11.2.1/version.py +1 -0
- approval_utilities-11.1.2/approval_utilities/utilities/multiline_string_utils.py +0 -10
- approval_utilities-11.1.2/tests/test_parse_inputs.py +0 -84
- approval_utilities-11.1.2/version.py +0 -1
- {approval_utilities-11.1.2 → approval_utilities-11.2.1}/LICENSE +0 -0
- {approval_utilities-11.1.2 → approval_utilities-11.2.1}/MANIFEST.in +0 -0
- {approval_utilities-11.1.2 → approval_utilities-11.2.1}/README.md +0 -0
- {approval_utilities-11.1.2 → approval_utilities-11.2.1}/approval_utilities/__init__.py +0 -0
- {approval_utilities-11.1.2 → approval_utilities-11.2.1}/approval_utilities/approvaltests/__init__.py +0 -0
- {approval_utilities-11.1.2 → approval_utilities-11.2.1}/approval_utilities/approvaltests/core/__init__.py +0 -0
- {approval_utilities-11.1.2 → approval_utilities-11.2.1}/approval_utilities/approvaltests/core/executable_command.py +0 -0
- {approval_utilities-11.1.2 → approval_utilities-11.2.1}/approval_utilities/approvaltests/core/verifiable.py +0 -0
- {approval_utilities-11.1.2 → approval_utilities-11.2.1}/approval_utilities/approvaltests/core/verify_parameters.py +0 -0
- {approval_utilities-11.1.2 → approval_utilities-11.2.1}/approval_utilities/list_utils.py +0 -0
- {approval_utilities-11.1.2 → approval_utilities-11.2.1}/approval_utilities/utilities/__init__.py +0 -0
- {approval_utilities-11.1.2 → approval_utilities-11.2.1}/approval_utilities/utilities/clipboard_utilities.py +0 -0
- {approval_utilities-11.1.2 → approval_utilities-11.2.1}/approval_utilities/utilities/deprecated.py +0 -0
- {approval_utilities-11.1.2 → approval_utilities-11.2.1}/approval_utilities/utilities/exceptions/__init__.py +0 -0
- {approval_utilities-11.1.2 → approval_utilities-11.2.1}/approval_utilities/utilities/exceptions/exception_collector.py +0 -0
- {approval_utilities-11.1.2 → approval_utilities-11.2.1}/approval_utilities/utilities/exceptions/exception_utils.py +0 -0
- {approval_utilities-11.1.2 → approval_utilities-11.2.1}/approval_utilities/utilities/exceptions/multiple_exceptions.py +0 -0
- {approval_utilities-11.1.2 → approval_utilities-11.2.1}/approval_utilities/utilities/logger/__init__.py +0 -0
- {approval_utilities-11.1.2 → approval_utilities-11.2.1}/approval_utilities/utilities/logger/logging_instance.py +0 -0
- {approval_utilities-11.1.2 → approval_utilities-11.2.1}/approval_utilities/utilities/logger/simple_logger.py +0 -0
- {approval_utilities-11.1.2 → approval_utilities-11.2.1}/approval_utilities/utilities/map_reduce.py +0 -0
- {approval_utilities-11.1.2 → approval_utilities-11.2.1}/approval_utilities/utilities/markdown_table.py +0 -0
- {approval_utilities-11.1.2 → approval_utilities-11.2.1}/approval_utilities/utilities/os_utilities.py +0 -0
- {approval_utilities-11.1.2 → approval_utilities-11.2.1}/approval_utilities/utilities/persistence/__init__.py +0 -0
- {approval_utilities-11.1.2 → approval_utilities-11.2.1}/approval_utilities/utilities/persistence/loader.py +0 -0
- {approval_utilities-11.1.2 → approval_utilities-11.2.1}/approval_utilities/utilities/persistence/saver.py +0 -0
- {approval_utilities-11.1.2 → approval_utilities-11.2.1}/approval_utilities/utilities/stack_frame_utilities.py +0 -0
- {approval_utilities-11.1.2 → approval_utilities-11.2.1}/approval_utilities/utilities/string_wrapper.py +0 -0
- {approval_utilities-11.1.2 → approval_utilities-11.2.1}/approval_utilities/utilities/time_utilities.py +0 -0
- {approval_utilities-11.1.2 → approval_utilities-11.2.1}/approval_utilities/utilities/wrapper.py +0 -0
- {approval_utilities-11.1.2 → approval_utilities-11.2.1}/approval_utilities/utils.py +0 -0
- {approval_utilities-11.1.2 → approval_utilities-11.2.1}/approval_utilities.egg-info/SOURCES.txt +0 -0
- {approval_utilities-11.1.2 → approval_utilities-11.2.1}/approval_utilities.egg-info/dependency_links.txt +0 -0
- {approval_utilities-11.1.2 → approval_utilities-11.2.1}/approval_utilities.egg-info/top_level.txt +0 -0
- {approval_utilities-11.1.2 → approval_utilities-11.2.1}/requirements.prod.extras.txt +0 -0
- {approval_utilities-11.1.2 → approval_utilities-11.2.1}/requirements.prod.required.txt +0 -0
- {approval_utilities-11.1.2 → approval_utilities-11.2.1}/requirements.prod.txt +0 -0
- {approval_utilities-11.1.2 → approval_utilities-11.2.1}/setup.cfg +0 -0
- {approval_utilities-11.1.2 → approval_utilities-11.2.1}/setup.py +0 -0
- {approval_utilities-11.1.2 → approval_utilities-11.2.1}/setup_utils.py +0 -0
- {approval_utilities-11.1.2 → approval_utilities-11.2.1}/tests/test_asserts.py +0 -0
- {approval_utilities-11.1.2 → approval_utilities-11.2.1}/tests/test_combinations.py +0 -0
- {approval_utilities-11.1.2 → approval_utilities-11.2.1}/tests/test_custom_printers.py +0 -0
- {approval_utilities-11.1.2 → approval_utilities-11.2.1}/tests/test_example_numpy.py +0 -0
- {approval_utilities-11.1.2 → approval_utilities-11.2.1}/tests/test_exception_utils.py +0 -0
- {approval_utilities-11.1.2 → approval_utilities-11.2.1}/tests/test_fileapprover.py +0 -0
- {approval_utilities-11.1.2 → approval_utilities-11.2.1}/tests/test_list.py +0 -0
- {approval_utilities-11.1.2 → approval_utilities-11.2.1}/tests/test_namer.py +0 -0
- {approval_utilities-11.1.2 → approval_utilities-11.2.1}/tests/test_options.py +0 -0
- {approval_utilities-11.1.2 → approval_utilities-11.2.1}/tests/test_pairwise_combinations.py +0 -0
- {approval_utilities-11.1.2 → approval_utilities-11.2.1}/tests/test_python_patterns.py +0 -0
- {approval_utilities-11.1.2 → approval_utilities-11.2.1}/tests/test_scenarios.py +0 -0
- {approval_utilities-11.1.2 → approval_utilities-11.2.1}/tests/test_simple_logger.py +0 -0
- {approval_utilities-11.1.2 → approval_utilities-11.2.1}/tests/test_split_code.py +0 -0
- {approval_utilities-11.1.2 → approval_utilities-11.2.1}/tests/test_verify.py +0 -0
- {approval_utilities-11.1.2 → approval_utilities-11.2.1}/tests/test_verify_all.py +0 -0
- {approval_utilities-11.1.2 → approval_utilities-11.2.1}/tests/test_writer.py +0 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import textwrap
|
|
2
|
+
|
|
3
|
+
from approval_utilities.utilities.logger.simple_logger import SimpleLogger
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def remove_indentation_from(text: str) -> str:
|
|
7
|
+
SimpleLogger.variable("text", text)
|
|
8
|
+
if not text:
|
|
9
|
+
return ""
|
|
10
|
+
cleaned = textwrap.dedent(text + "|")
|
|
11
|
+
if cleaned.startswith("\n"):
|
|
12
|
+
cleaned = cleaned[1:]
|
|
13
|
+
return cleaned[:-1]
|
|
@@ -159,3 +159,41 @@ class InlineTests(unittest.TestCase):
|
|
|
159
159
|
arg2=(2, 4),
|
|
160
160
|
options=Options().inline(show_code=False),
|
|
161
161
|
)
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
def get_preceding_whitespace():
|
|
165
|
+
return " 4 whitespaces"
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
# fmt: off
|
|
169
|
+
def test_preceding_whitespace():
|
|
170
|
+
"""
|
|
171
|
+
4 whitespaces
|
|
172
|
+
"""
|
|
173
|
+
verify(get_preceding_whitespace(), options=Options().inline(show_code=True))
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
def test_trailing_whitespace():
|
|
177
|
+
"""
|
|
178
|
+
4 trailing whitespaces
|
|
179
|
+
"""
|
|
180
|
+
# Note: Pycharm will remove the trailing whitespaces, to disable this go to:
|
|
181
|
+
# File -> Settings -> Editor -> General -> On Save -> [ ] Remove trailing spaces
|
|
182
|
+
verify("4 trailing whitespaces ", options=Options().inline(show_code=False))
|
|
183
|
+
|
|
184
|
+
# fmt: on
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
def test_bug_blank_lines():
|
|
188
|
+
"""
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
test bug with blank lines
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
"""
|
|
196
|
+
verify(
|
|
197
|
+
"\n\ntest bug with blank lines\n\n\n\n",
|
|
198
|
+
options=Options().inline(show_code=True),
|
|
199
|
+
)
|
{approval_utilities-11.1.2 → approval_utilities-11.2.1}/tests/test_multiline_string_utils.py
RENAMED
|
@@ -19,3 +19,17 @@ def test_remove_indentation_from_works_perfectly() -> None:
|
|
|
19
19
|
"""
|
|
20
20
|
)
|
|
21
21
|
verify("remove_indentation_from\n" + text)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def test_remove_indentation_uses_the_last_line_as_max_whitespace():
|
|
25
|
+
input = """
|
|
26
|
+
4 whitespaces
|
|
27
|
+
"""
|
|
28
|
+
assert " 4 whitespaces\n" == remove_indentation_from(input)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def test_trailing_whitespace():
|
|
32
|
+
input = """
|
|
33
|
+
4 trailing whitespaces
|
|
34
|
+
"""
|
|
35
|
+
assert "4 trailing whitespaces \n" == remove_indentation_from(input)
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
from approvaltests import Options, verify_all
|
|
2
|
+
from approvaltests.inline.parse import Parse
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def test_single_strings():
|
|
6
|
+
"""
|
|
7
|
+
Sam -> SAM
|
|
8
|
+
Llewellyn -> LLEWELLYN
|
|
9
|
+
"""
|
|
10
|
+
parse = Parse.doc_string()
|
|
11
|
+
verify_all(
|
|
12
|
+
"",
|
|
13
|
+
parse.get_inputs(),
|
|
14
|
+
lambda s: f"{s} -> {s.upper()}",
|
|
15
|
+
options=Options().inline(),
|
|
16
|
+
)
|
|
17
|
+
parse.verify_all(lambda s: s.upper())
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def test_with_types_transformers_and_both():
|
|
21
|
+
"""
|
|
22
|
+
1 -> 0b1
|
|
23
|
+
9 -> 0b1001
|
|
24
|
+
"""
|
|
25
|
+
parse = Parse.doc_string()
|
|
26
|
+
verify_all(
|
|
27
|
+
"",
|
|
28
|
+
parse.get_inputs(),
|
|
29
|
+
lambda s: f"{s} -> {bin(int(s))}",
|
|
30
|
+
options=Options().inline(),
|
|
31
|
+
)
|
|
32
|
+
parse.transform(lambda a: int(a)).verify_all(lambda i: bin(i))
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
# parse.transform(int).transform(str).transform(int).verify_all(lambda i: bin(i), options= Options().with_reporter(ReporterThatAutomaticallyApproves())
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def test_with_2_types_transformers_and_both():
|
|
39
|
+
"""
|
|
40
|
+
1, 5.0 -> 5.0
|
|
41
|
+
4, 0.5 -> 2.0
|
|
42
|
+
"""
|
|
43
|
+
parse = Parse.doc_string(auto_approve=True)
|
|
44
|
+
parse.transform2(int, float).verify_all(lambda i, f: i * f)
|
|
45
|
+
parse.transform2(str, str).transform2(int, float).verify_all(lambda i, f: i * f)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def test_example_step_1():
|
|
49
|
+
# begin-snippet: parse_input_step_2
|
|
50
|
+
"""
|
|
51
|
+
Kody -> 0
|
|
52
|
+
"""
|
|
53
|
+
|
|
54
|
+
# end-snippet
|
|
55
|
+
# begin-snippet: parse_input_step_1
|
|
56
|
+
def count_vowels(s: str) -> int:
|
|
57
|
+
return 0
|
|
58
|
+
|
|
59
|
+
def test_count_vowels():
|
|
60
|
+
"""
|
|
61
|
+
Kody
|
|
62
|
+
"""
|
|
63
|
+
parse = Parse.doc_string(auto_approve=True)
|
|
64
|
+
parse.verify_all(count_vowels)
|
|
65
|
+
|
|
66
|
+
# end-snippet
|
|
67
|
+
test_count_vowels()
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def test_example_step_2():
|
|
71
|
+
"""
|
|
72
|
+
Kody -> 1
|
|
73
|
+
Teresa -> 3
|
|
74
|
+
Green -> 2
|
|
75
|
+
"""
|
|
76
|
+
|
|
77
|
+
# begin-snippet: parse_input_step_3
|
|
78
|
+
def count_vowels(s: str) -> int:
|
|
79
|
+
return sum(1 for c in s if c in "aeo")
|
|
80
|
+
|
|
81
|
+
def test_count_vowels():
|
|
82
|
+
"""
|
|
83
|
+
Kody -> 1
|
|
84
|
+
Teresa -> 3
|
|
85
|
+
Green -> 2
|
|
86
|
+
"""
|
|
87
|
+
parse = Parse.doc_string(auto_approve=True)
|
|
88
|
+
parse.verify_all(count_vowels)
|
|
89
|
+
|
|
90
|
+
# end-snippet
|
|
91
|
+
test_count_vowels()
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
# begin-snippet: parse_input_transformation
|
|
95
|
+
def test_with_transformation():
|
|
96
|
+
"""
|
|
97
|
+
1 -> 0b1
|
|
98
|
+
9 -> 0b1001
|
|
99
|
+
"""
|
|
100
|
+
parse = Parse.doc_string(auto_approve=True)
|
|
101
|
+
parse.transform(int).verify_all(bin)
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
# end-snippet
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
# begin-snippet: parse_input_two_parameters
|
|
108
|
+
def test_with_two_parameters():
|
|
109
|
+
"""
|
|
110
|
+
a, 3 -> aaa
|
|
111
|
+
!, 7 -> !!!!!!!
|
|
112
|
+
"""
|
|
113
|
+
parse = Parse.doc_string(auto_approve=True)
|
|
114
|
+
parse.transform2(str, int).verify_all(lambda s, i: s * i)
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
# end-snippet
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
version_number = "v11.2.1"
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
from typing import List, Callable, Any
|
|
2
|
-
|
|
3
|
-
from approvaltests import Options, verify_all
|
|
4
|
-
from approvaltests.namer.inline_comparator import InlineComparator
|
|
5
|
-
|
|
6
|
-
from typing import TypeVar, Generic
|
|
7
|
-
|
|
8
|
-
from build.lib.approvaltests.reporters import ReporterThatAutomaticallyApproves
|
|
9
|
-
|
|
10
|
-
T = TypeVar("T")
|
|
11
|
-
T2 = TypeVar("T2")
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
class Parse(Generic[T]):
|
|
15
|
-
def __init__(self, text: str, transformer: Callable[[str], T]) -> None:
|
|
16
|
-
self.text = text
|
|
17
|
-
self._transformer = transformer
|
|
18
|
-
|
|
19
|
-
@staticmethod
|
|
20
|
-
def doc_string() -> "Parse[str]":
|
|
21
|
-
return Parse(InlineComparator.get_test_method_doc_string(), lambda s: s)
|
|
22
|
-
|
|
23
|
-
def get_inputs(self) -> List[T]:
|
|
24
|
-
lines = self.text.split("\n")
|
|
25
|
-
lines = list(filter(lambda line: line.strip(), lines))
|
|
26
|
-
inputs = [line.split("->")[0].strip() for line in lines]
|
|
27
|
-
return [self._transformer(i) for i in inputs]
|
|
28
|
-
|
|
29
|
-
def verify_all(self, transform: Callable[[T], Any]):
|
|
30
|
-
verify_all(
|
|
31
|
-
"",
|
|
32
|
-
self.get_inputs(),
|
|
33
|
-
lambda s: f"{s} -> {transform(s)}",
|
|
34
|
-
options=Options().inline(),
|
|
35
|
-
)
|
|
36
|
-
|
|
37
|
-
def transform(self, transform: Callable[[T], T2]) -> "Parse[T2]":
|
|
38
|
-
return Parse(self.text, lambda s: transform(self._transformer(s)))
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
def test_single_strings():
|
|
42
|
-
"""
|
|
43
|
-
Sam -> SAM
|
|
44
|
-
Llewellyn -> LLEWELLYN
|
|
45
|
-
"""
|
|
46
|
-
parse = Parse.doc_string()
|
|
47
|
-
verify_all(
|
|
48
|
-
"",
|
|
49
|
-
parse.get_inputs(),
|
|
50
|
-
lambda s: f"{s} -> {s.upper()}",
|
|
51
|
-
options=Options().inline(),
|
|
52
|
-
)
|
|
53
|
-
parse.verify_all(lambda s: s.upper())
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
def test_with_types_transformers_and_both():
|
|
57
|
-
"""
|
|
58
|
-
1 -> 0b1
|
|
59
|
-
9 -> 0b1001
|
|
60
|
-
"""
|
|
61
|
-
parse = Parse.doc_string()
|
|
62
|
-
verify_all(
|
|
63
|
-
"",
|
|
64
|
-
parse.get_inputs(),
|
|
65
|
-
lambda s: f"{s} -> {bin(int(s))}",
|
|
66
|
-
options=Options().inline(),
|
|
67
|
-
)
|
|
68
|
-
parse.transform(int).verify_all(lambda i: bin(i))
|
|
69
|
-
parse.transform(lambda a: int(a)).verify_all(lambda i: bin(i))
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
# parse.transform(int).transform(str).transform(int).verify_all(lambda i: bin(i), options= Options().with_reporter(ReporterThatAutomaticallyApproves())
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
def test_with_2_types_transformers_and_both():
|
|
76
|
-
"""
|
|
77
|
-
1, 2.2 -> 2.2
|
|
78
|
-
4, 0.5 -> 2
|
|
79
|
-
"""
|
|
80
|
-
s = "2.2"
|
|
81
|
-
parse = Parse.doc_string()
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
# parse.transform2(int, float).verify_all(lambda i,f: i * f)
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
version_number = "v11.1.2"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{approval_utilities-11.1.2 → approval_utilities-11.2.1}/approval_utilities/approvaltests/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{approval_utilities-11.1.2 → approval_utilities-11.2.1}/approval_utilities/utilities/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{approval_utilities-11.1.2 → approval_utilities-11.2.1}/approval_utilities/utilities/deprecated.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{approval_utilities-11.1.2 → approval_utilities-11.2.1}/approval_utilities/utilities/map_reduce.py
RENAMED
|
File without changes
|
|
File without changes
|
{approval_utilities-11.1.2 → approval_utilities-11.2.1}/approval_utilities/utilities/os_utilities.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{approval_utilities-11.1.2 → approval_utilities-11.2.1}/approval_utilities/utilities/wrapper.py
RENAMED
|
File without changes
|
|
File without changes
|
{approval_utilities-11.1.2 → approval_utilities-11.2.1}/approval_utilities.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{approval_utilities-11.1.2 → approval_utilities-11.2.1}/approval_utilities.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|