approval-utilities 11.1.3__tar.gz → 12.0.0__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.

Files changed (66) hide show
  1. {approval_utilities-11.1.3/approval_utilities.egg-info → approval_utilities-12.0.0}/PKG-INFO +1 -1
  2. {approval_utilities-11.1.3 → approval_utilities-12.0.0}/README.md +1 -1
  3. {approval_utilities-11.1.3 → approval_utilities-12.0.0/approval_utilities.egg-info}/PKG-INFO +1 -1
  4. {approval_utilities-11.1.3 → approval_utilities-12.0.0}/tests/test_inline_approvals.py +11 -33
  5. approval_utilities-12.0.0/tests/test_parse_inputs.py +145 -0
  6. approval_utilities-12.0.0/version.py +1 -0
  7. approval_utilities-11.1.3/tests/test_parse_inputs.py +0 -84
  8. approval_utilities-11.1.3/version.py +0 -1
  9. {approval_utilities-11.1.3 → approval_utilities-12.0.0}/LICENSE +0 -0
  10. {approval_utilities-11.1.3 → approval_utilities-12.0.0}/MANIFEST.in +0 -0
  11. {approval_utilities-11.1.3 → approval_utilities-12.0.0}/approval_utilities/__init__.py +0 -0
  12. {approval_utilities-11.1.3 → approval_utilities-12.0.0}/approval_utilities/approvaltests/__init__.py +0 -0
  13. {approval_utilities-11.1.3 → approval_utilities-12.0.0}/approval_utilities/approvaltests/core/__init__.py +0 -0
  14. {approval_utilities-11.1.3 → approval_utilities-12.0.0}/approval_utilities/approvaltests/core/executable_command.py +0 -0
  15. {approval_utilities-11.1.3 → approval_utilities-12.0.0}/approval_utilities/approvaltests/core/verifiable.py +0 -0
  16. {approval_utilities-11.1.3 → approval_utilities-12.0.0}/approval_utilities/approvaltests/core/verify_parameters.py +0 -0
  17. {approval_utilities-11.1.3 → approval_utilities-12.0.0}/approval_utilities/list_utils.py +0 -0
  18. {approval_utilities-11.1.3 → approval_utilities-12.0.0}/approval_utilities/utilities/__init__.py +0 -0
  19. {approval_utilities-11.1.3 → approval_utilities-12.0.0}/approval_utilities/utilities/clipboard_utilities.py +0 -0
  20. {approval_utilities-11.1.3 → approval_utilities-12.0.0}/approval_utilities/utilities/deprecated.py +0 -0
  21. {approval_utilities-11.1.3 → approval_utilities-12.0.0}/approval_utilities/utilities/exceptions/__init__.py +0 -0
  22. {approval_utilities-11.1.3 → approval_utilities-12.0.0}/approval_utilities/utilities/exceptions/exception_collector.py +0 -0
  23. {approval_utilities-11.1.3 → approval_utilities-12.0.0}/approval_utilities/utilities/exceptions/exception_utils.py +0 -0
  24. {approval_utilities-11.1.3 → approval_utilities-12.0.0}/approval_utilities/utilities/exceptions/multiple_exceptions.py +0 -0
  25. {approval_utilities-11.1.3 → approval_utilities-12.0.0}/approval_utilities/utilities/logger/__init__.py +0 -0
  26. {approval_utilities-11.1.3 → approval_utilities-12.0.0}/approval_utilities/utilities/logger/logging_instance.py +0 -0
  27. {approval_utilities-11.1.3 → approval_utilities-12.0.0}/approval_utilities/utilities/logger/simple_logger.py +0 -0
  28. {approval_utilities-11.1.3 → approval_utilities-12.0.0}/approval_utilities/utilities/map_reduce.py +0 -0
  29. {approval_utilities-11.1.3 → approval_utilities-12.0.0}/approval_utilities/utilities/markdown_table.py +0 -0
  30. {approval_utilities-11.1.3 → approval_utilities-12.0.0}/approval_utilities/utilities/multiline_string_utils.py +0 -0
  31. {approval_utilities-11.1.3 → approval_utilities-12.0.0}/approval_utilities/utilities/os_utilities.py +0 -0
  32. {approval_utilities-11.1.3 → approval_utilities-12.0.0}/approval_utilities/utilities/persistence/__init__.py +0 -0
  33. {approval_utilities-11.1.3 → approval_utilities-12.0.0}/approval_utilities/utilities/persistence/loader.py +0 -0
  34. {approval_utilities-11.1.3 → approval_utilities-12.0.0}/approval_utilities/utilities/persistence/saver.py +0 -0
  35. {approval_utilities-11.1.3 → approval_utilities-12.0.0}/approval_utilities/utilities/stack_frame_utilities.py +0 -0
  36. {approval_utilities-11.1.3 → approval_utilities-12.0.0}/approval_utilities/utilities/string_wrapper.py +0 -0
  37. {approval_utilities-11.1.3 → approval_utilities-12.0.0}/approval_utilities/utilities/time_utilities.py +0 -0
  38. {approval_utilities-11.1.3 → approval_utilities-12.0.0}/approval_utilities/utilities/wrapper.py +0 -0
  39. {approval_utilities-11.1.3 → approval_utilities-12.0.0}/approval_utilities/utils.py +0 -0
  40. {approval_utilities-11.1.3 → approval_utilities-12.0.0}/approval_utilities.egg-info/SOURCES.txt +0 -0
  41. {approval_utilities-11.1.3 → approval_utilities-12.0.0}/approval_utilities.egg-info/dependency_links.txt +0 -0
  42. {approval_utilities-11.1.3 → approval_utilities-12.0.0}/approval_utilities.egg-info/top_level.txt +0 -0
  43. {approval_utilities-11.1.3 → approval_utilities-12.0.0}/requirements.prod.extras.txt +0 -0
  44. {approval_utilities-11.1.3 → approval_utilities-12.0.0}/requirements.prod.required.txt +0 -0
  45. {approval_utilities-11.1.3 → approval_utilities-12.0.0}/requirements.prod.txt +0 -0
  46. {approval_utilities-11.1.3 → approval_utilities-12.0.0}/setup.cfg +0 -0
  47. {approval_utilities-11.1.3 → approval_utilities-12.0.0}/setup.py +0 -0
  48. {approval_utilities-11.1.3 → approval_utilities-12.0.0}/setup_utils.py +0 -0
  49. {approval_utilities-11.1.3 → approval_utilities-12.0.0}/tests/test_asserts.py +0 -0
  50. {approval_utilities-11.1.3 → approval_utilities-12.0.0}/tests/test_combinations.py +0 -0
  51. {approval_utilities-11.1.3 → approval_utilities-12.0.0}/tests/test_custom_printers.py +0 -0
  52. {approval_utilities-11.1.3 → approval_utilities-12.0.0}/tests/test_example_numpy.py +0 -0
  53. {approval_utilities-11.1.3 → approval_utilities-12.0.0}/tests/test_exception_utils.py +0 -0
  54. {approval_utilities-11.1.3 → approval_utilities-12.0.0}/tests/test_fileapprover.py +0 -0
  55. {approval_utilities-11.1.3 → approval_utilities-12.0.0}/tests/test_list.py +0 -0
  56. {approval_utilities-11.1.3 → approval_utilities-12.0.0}/tests/test_multiline_string_utils.py +0 -0
  57. {approval_utilities-11.1.3 → approval_utilities-12.0.0}/tests/test_namer.py +0 -0
  58. {approval_utilities-11.1.3 → approval_utilities-12.0.0}/tests/test_options.py +0 -0
  59. {approval_utilities-11.1.3 → approval_utilities-12.0.0}/tests/test_pairwise_combinations.py +0 -0
  60. {approval_utilities-11.1.3 → approval_utilities-12.0.0}/tests/test_python_patterns.py +0 -0
  61. {approval_utilities-11.1.3 → approval_utilities-12.0.0}/tests/test_scenarios.py +0 -0
  62. {approval_utilities-11.1.3 → approval_utilities-12.0.0}/tests/test_simple_logger.py +0 -0
  63. {approval_utilities-11.1.3 → approval_utilities-12.0.0}/tests/test_split_code.py +0 -0
  64. {approval_utilities-11.1.3 → approval_utilities-12.0.0}/tests/test_verify.py +0 -0
  65. {approval_utilities-11.1.3 → approval_utilities-12.0.0}/tests/test_verify_all.py +0 -0
  66. {approval_utilities-11.1.3 → approval_utilities-12.0.0}/tests/test_writer.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: approval_utilities
3
- Version: 11.1.3
3
+ Version: 12.0.0
4
4
  Summary: Utilities for your production code that work well with approvaltests
5
5
  Home-page: https://github.com/approvals/ApprovalTests.Python
6
6
  Author: ApprovalTests Contributors
@@ -50,7 +50,7 @@ utilities.
50
50
 
51
51
  ### What Are Approvals
52
52
 
53
- If you need to gain a better understanding or are new to this concept, start [here](docs/explanation/what_are_approvals.md).
53
+ If you need to gain a better understanding or are new to this concept, start [here](https://github.com/approvals/ApprovalTests.Documentation/blob/main/explanations/what_are_approvals.md).
54
54
 
55
55
  ### New Projects
56
56
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: approval_utilities
3
- Version: 11.1.3
3
+ Version: 12.0.0
4
4
  Summary: Utilities for your production code that work well with approvaltests
5
5
  Home-page: https://github.com/approvals/ApprovalTests.Python
6
6
  Author: ApprovalTests Contributors
@@ -1,24 +1,20 @@
1
1
  import unittest
2
2
  from inspect import FrameInfo
3
- from pathlib import Path
4
3
  from typing import Callable, Any
5
4
 
6
5
  import pytest
7
6
 
8
- from approval_utilities.utilities.clipboard_utilities import copy_to_clipboard
9
7
  from approval_utilities.utilities.multiline_string_utils import remove_indentation_from
10
8
  from approvaltests import (
11
9
  StackFrameNamer,
12
- assert_equal_with_reporter,
13
10
  Options,
14
- Reporter,
15
11
  verify,
16
12
  verify_all,
17
13
  verify_all_combinations_with_labeled_input,
18
14
  ApprovalException,
19
15
  )
16
+ from approvaltests.inline.inline_options import InlineOptions
20
17
  from approvaltests.inline.parse_docstring import parse_docstring
21
- from approvaltests.reporters import MultiReporter, ReportWithBeyondCompare
22
18
  from approvaltests.reporters.report_quietly import ReportQuietly
23
19
 
24
20
 
@@ -76,30 +72,13 @@ def test_docstrings():
76
72
  """
77
73
  # verify_inline(greetting())
78
74
  # verify(greetting(), options=Options().inline(show_code= False))
79
- verify(greeting(), options=Options().inline(show_code=True))
75
+ verify(greeting(), options=Options().inline())
80
76
 
81
77
 
82
78
  def greeting():
83
79
  return "hello\nworld"
84
80
 
85
81
 
86
- class InlineReporter(Reporter):
87
- # TODO: Start here - Make this report create a temp file of the fixed source,
88
- # and compare it with the existing source.
89
- # if there are mulitple failures, they each get there on reporter
90
- def report(self, received_path: str, approved_path: str) -> bool:
91
- received = Path(received_path).read_text()
92
- copy_to_clipboard(f"'''\n{received}\n'''")
93
-
94
-
95
- def verify_inline(actual):
96
- options = Options()
97
- options = options.with_reporter(MultiReporter(options.reporter, InlineReporter()))
98
- if actual[-1] != "\n":
99
- actual += "\n"
100
- assert_equal_with_reporter(get_approved_via_doc_string(), actual, options=options)
101
-
102
-
103
82
  def test_docstring_parsing():
104
83
  """
105
84
  1
@@ -157,7 +136,7 @@ class InlineTests(unittest.TestCase):
157
136
  lambda a, b: a + b,
158
137
  arg1=(1, 3),
159
138
  arg2=(2, 4),
160
- options=Options().inline(show_code=False),
139
+ options=Options().inline(),
161
140
  )
162
141
 
163
142
 
@@ -165,23 +144,25 @@ def get_preceding_whitespace():
165
144
  return " 4 whitespaces"
166
145
 
167
146
 
147
+ # fmt: off
168
148
  def test_preceding_whitespace():
169
149
  """
170
- 4 whitespaces
150
+ 4 whitespaces
171
151
  """
172
- verify(get_preceding_whitespace(), options=Options().inline(show_code=True))
152
+ verify(get_preceding_whitespace(), options=Options().inline())
173
153
 
174
154
 
175
155
  def test_trailing_whitespace():
176
156
  """
177
- 4 trailing whitespaces
157
+ 4 trailing whitespaces
178
158
  """
179
159
  # Note: Pycharm will remove the trailing whitespaces, to disable this go to:
180
160
  # File -> Settings -> Editor -> General -> On Save -> [ ] Remove trailing spaces
181
- verify("4 trailing whitespaces ", options=Options().inline(show_code=False))
161
+ verify("4 trailing whitespaces ", options=Options().inline())
162
+
163
+ # fmt: on
182
164
 
183
165
 
184
- # 2. [ ] fix inline bug with blank lines <- from todo list
185
166
  def test_bug_blank_lines():
186
167
  """
187
168
 
@@ -191,7 +172,4 @@ def test_bug_blank_lines():
191
172
 
192
173
 
193
174
  """
194
- verify(
195
- "\n\ntest bug with blank lines\n\n\n\n",
196
- options=Options().inline(show_code=True),
197
- )
175
+ verify("\n\ntest bug with blank lines\n\n\n\n", options=Options().inline())
@@ -0,0 +1,145 @@
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
118
+
119
+
120
+ # long-term intention: get the test to fail, randomSauce is incorrect
121
+ def test_with_3_parameters():
122
+ """
123
+ a, 3, 1 -> aaaa
124
+ """
125
+
126
+ counter = 0
127
+
128
+ def to(tin: type, tout: type):
129
+ def wrapped(input):
130
+ nonlocal counter
131
+ counter += 1
132
+ assert type(input) is tin
133
+ return tout(input)
134
+
135
+ return wrapped
136
+
137
+ parse = Parse.doc_string(auto_approve=True)
138
+ parse.transform3(to(str, str), to(str, str), to(str, str)).transform3(
139
+ to(str, str), to(str, int), to(str, int)
140
+ ).verify_all(lambda a, b, c: to(str, str)(a) * (to(int, int)(b) + to(int, int)(c)))
141
+
142
+ assert counter == 9
143
+
144
+
145
+ # assert on all the paramaters
@@ -0,0 +1 @@
1
+ version_number = "v12.0.0"
@@ -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.3"