punit 0.0.27__py3-none-any.whl

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.
@@ -0,0 +1,5 @@
1
+ # SPDX-FileCopyrightText: © 2024 Shaun Wilson
2
+ # SPDX-License-Identifier: MIT
3
+
4
+ from .Theory import Theory, theory, inlinedata
5
+ from .TheoryManager import TheoryManager
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Shaun Wilson
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,174 @@
1
+ Metadata-Version: 2.2
2
+ Name: punit
3
+ Version: 0.0.27
4
+ Summary: A modernized unit-test framework for Python.
5
+ Author-email: Shaun Wilson <mrshaunwilson@msn.com>
6
+ Project-URL: Documentation, https://punit.readthedocs.io/
7
+ Project-URL: Homepage, https://github.com/wilson0x4d/punit
8
+ Project-URL: Repository, https://github.com/wilson0x4d/punit.git
9
+ Keywords: test,unittest,unit-test
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: Programming Language :: Python :: 3.13
14
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
15
+ Classifier: Intended Audience :: Developers
16
+ Requires-Python: >=3.12
17
+ Description-Content-Type: text/markdown
18
+ License-File: LICENSE
19
+
20
+ `pUnit` is a modernized unit-testing framework for Python, inspired by xUnit.
21
+
22
+ This README is only a high-level introduction to **pUnit**. For more detailed documentation, please view the official docs at [https://pUnit.readthedocs.io](https://pUnit.readthedocs.io).
23
+
24
+ ## Command-Line Usage
25
+
26
+ Running pUnit with no arguments will perform test auto-discovery and execution:
27
+
28
+ ```bash
29
+ python3 -m punit
30
+ ```
31
+
32
+ By default it will look for tests in the `tests/` directory. You can override this behavior by providing a `--test-package` argument:
33
+
34
+ ```bash
35
+ python3 -m punit --test-package elsewhere
36
+ ```
37
+
38
+ In the above example, test discovery will instead occur in an `elsewhere/` directory.
39
+
40
+ ### Report Generation
41
+
42
+ `pUnit` can generate "Test Results" reports. Currently supporting HTML and jUnit formats:
43
+
44
+ ```bash
45
+ python3 -m punit --report html
46
+ ```
47
+
48
+ Reports can also be output to a file where they can be lifted as part of a CI/CD pipeline and stored as an artifact or used for other purposes:
49
+
50
+ ```bash
51
+ python3 -m punit --report junit --output results.xml
52
+ ```
53
+
54
+ ### Syntax Help
55
+
56
+ There are more options available, passing a `--help` argument will print help text:
57
+
58
+ ```bash
59
+ python3 -m punit --help
60
+ ```
61
+ Outputs:
62
+ ```plaintext
63
+ Usage: python3 -m punit [-h|--help]
64
+ [-q|--quiet] [-v|--verbose]
65
+ [-f|--failfast]
66
+ [-p|--test-package NAME]
67
+ [-i|--include PATTERN]
68
+ [-e|--exclude PATTERN]
69
+ [-t|--filter PATTERN]
70
+ [-w|--workdir DIRECTORY]
71
+ [-n|--no-default-patterns]
72
+ [-r|--report {junit|json}]
73
+ [-o|--output FILENAME]
74
+
75
+ Options:
76
+ -h, --help Show this help text and exit
77
+ -q, --quiet Quiet output
78
+ -v, --verbose Verbose output
79
+ -f, --failfast Stop on first failure or error
80
+ -p, --test-package NAME
81
+ Use NAME as the test package, all tests should
82
+ be locatable as modules in the named package.
83
+ Default: 'tests'
84
+ -i, --include PATTERN
85
+ Include any tests matching PATTERN
86
+ Default: '*.py'
87
+ -e, --exclude PATTERN
88
+ Exclude any tests matching PATTERN, overriding --include
89
+ Default: '__*__' (dunder files), '/.*/' (dot-directories)
90
+ -t, --filter PATTERN
91
+ Only execute tests matching PATTERN
92
+ Default: '*'
93
+ -w, --working-directory DIRECTORY
94
+ Working directory (defaults to start directory)
95
+ -n, --no-default-patterns
96
+ Do not apply any default include/exclude patterns.
97
+ -r, --report {html|junit}
98
+ Generate a report to stdout using either an "html"
99
+ or "junit" format. When generating a report to stdout
100
+ all other output is suppressed, unless `--output`
101
+ is also specified.
102
+ -o, --output FILENAME
103
+ If `--report` is used, instead of writing to stdout
104
+ write to FILENAME. In this case `--report` does not
105
+ suppress any program output.
106
+ ```
107
+
108
+ ## Writing Tests
109
+
110
+ You can write tests as functions, class methods, instance methods, or static methods with all forms offering identical functionality. You can also utilize async/await syntax without any additional overhead.
111
+
112
+ **pUnit** is based upon the fundamental concepts of `Facts` and `Theories`. These are codified using decorators, aptly named `@fact` and `@theory`. Consider these examples:
113
+
114
+ ```python
115
+
116
+ from punit import *
117
+
118
+ @fact
119
+ async def MyLibrary_WhenInitialized_TouchMustReturnTrue:
120
+ mylib = MyLibrary()
121
+ mylib.initialize()
122
+ await asyncio.sleep(1)
123
+ assert mylib.touch(), "Expecting touch() to return true, because initialize() was called."
124
+
125
+ class MyTestFixture:
126
+
127
+ def calc(number:int|None = None):
128
+ if number == None:
129
+ raise Exception('Invalid value "None".')
130
+ return number * number
131
+
132
+ @theory
133
+ @inlinedata(0, 0)
134
+ @inlinedata(1, 1)
135
+ @inlinedata(2, 4)
136
+ @inlinedata(3, 9)
137
+ @inlinedata(5, 25)
138
+ @inlinedata(8, 64)
139
+ def verifyCalcAssumptions(self, number:int, expected:int) -> None:
140
+ assert expected == self.calc(number)
141
+
142
+ @fact
143
+ def verifyCalcErrorCondition(self) -> None:
144
+ from punit.exceptions import raises
145
+ # assert errors are raised, or not
146
+ def calc_None():
147
+ self.calc(None)
148
+ def calc_1()
149
+ self.calc(1)
150
+ assert raises[Exception](calc_None)
151
+ assert not raises[Exception](calc_1)
152
+ ```
153
+
154
+ Because `pUnit` is a decorative framework you are afforded the utmost freedom in how you structure and implement your tests.
155
+
156
+ Unlike other testing frameworks, the names you use for functions, classes, and methods is not relevant. There is no requirement to inherit classes from specific abstract/base classes for any particular functionality. There is no requirement that your tests be organized into modules with `__init__.py` files.
157
+
158
+ You will want to take particular note of the `--exclude` command-line parameter which allows you to restrict what `pUnit` will consider to be a valid test file. While the default behavior will fit 99% of use-cases, you _can_ exercise more control over the discovery process.
159
+
160
+ ## Vision, Future, and LTS
161
+
162
+ The long-term vision is to provide both imperative and declarative syntaxes for testing while keeping `pUnit` as simple as possible in its implementation.
163
+
164
+ `pUnit` is a Python 3.12+ package and there are no plans to backport it to earlier versions of Python, however, user contributions to support backward compatibility _will be accepted_ when it makes sense.
165
+
166
+ As Python progresses so will `pUnit` and SEMVER rules will be respected to provide developers with assurance that a major version of `pUnit` is fit for a particular purpose, thus, if there is ever a breaking change in Python that requires a breaking change in `pUnit` you can expect `pUnit` versioning to reflect this.
167
+
168
+ In any situation where an undocumented feature may be used maintainers will actively keep watch on deprecation notices and removals, will clearly identify these dependencies in the docs, and most importantly will provide a LTS alternative to any undocumented feature or such features will not be included in `pUnit`.
169
+
170
+ With respect to long-term support, we will commit to maintaining major versions for 3 years from the date they were superceded by a new major version. This should align well with Python Core Development.
171
+
172
+ ## Contact
173
+
174
+ You can reach me on [Discord](https://discordapp.com/users/307684202080501761) or [open an Issue on Github](https://github.com/wilson0x4d/punit/issues/new/choose).
@@ -0,0 +1,24 @@
1
+ punit/TestResult.py,sha256=-yL2ql4vMGCHVoOkS96TFwMcaNmeHsfsX2Q_tIPQdsk,4689
2
+ punit/__init__.py,sha256=linCZsiSlOdMG-QOY9pkzNCL4R7PDFk1tvLnVmaZrSY,174
3
+ punit/__main__.py,sha256=vUlQ576wizb5oWf_Talaj-5imYyUYwjkGNV2f005z80,1742
4
+ punit/cli.py,sha256=Kwi9YM7xsvR3k6nUZfO7mIrMhZlh_xxbIm3I6GtHNHc,9134
5
+ punit/runner.py,sha256=7xtychPTodS0YZiKpnSUCRrMzbnWPwdv_sWLBweOz_g,5507
6
+ punit/assertions/__init__.py,sha256=pL9U-03ygNUN2PYxAWy82HIVth5JnuFFv6QxrkF5EBw,129
7
+ punit/assertions/collections.py,sha256=Ad4q4naywdx_V_kZqGhb3QwaNurComnr2IyQvkWm2Tw,475
8
+ punit/assertions/exceptions.py,sha256=SXijWESvKhB2HfNs8zp0YTmmYZEqn1sBeKoPXJ1Ui3k,949
9
+ punit/discovery/TestModuleDiscovery.py,sha256=40b-wwMfqIJkSQXcbIHE2G_M8clxkg5ViW_3Or-KKSk,4047
10
+ punit/discovery/__init__.py,sha256=Hq9JPoj6HTdRSg1nXYaZatBzd7xit4r_9chCJptMIv4,155
11
+ punit/facts/Fact.py,sha256=LNuHbFAZuBKot4ar0tJ3UjGJc2U241B-HsZYkoY5Ed8,2373
12
+ punit/facts/FactManager.py,sha256=yJ66nVemwsbv6zK3MNNNoCvksMNb2tYv98KJ50OHhow,1456
13
+ punit/facts/__init__.py,sha256=hec0Dk7EFqO_b-I3nZK1Lc3EcQICqEWYjgdyQ8J1Fao,145
14
+ punit/reports/HtmlReportGenerator.py,sha256=e0iP9GFlKnFnl0LBOCO4E_qcQ0KfwQjClTBCVw8HIwg,5305
15
+ punit/reports/JUnitReportGenerator.py,sha256=3pF8xihrdAI1NnaQYPP1ttOkauEINzjP4qETFb09x4Q,7269
16
+ punit/reports/__init__.py,sha256=Zdsh13lxDvySR5PLSmGSceI1gNNLyMaxenQmndp8RLs,187
17
+ punit/theories/Theory.py,sha256=0qjYE3kSgVqXEajNVXDQegHHgo94WzuDK9oCHa__ip0,2863
18
+ punit/theories/TheoryManager.py,sha256=I3ce6DSlO7MaRtpEkj7Mroox3bYNc_UKCVW3SGgji6E,2255
19
+ punit/theories/__init__.py,sha256=t6WEFWB_PMhIf9g61MiASdQ0bnugVlz3-VxoMvsTUuw,167
20
+ punit-0.0.27.dist-info/LICENSE,sha256=Nx4FiJyAL1Wc7SDApa9RYVQafnPCbOC9SCPRqQRtcW0,1069
21
+ punit-0.0.27.dist-info/METADATA,sha256=BDXtwAu3AxfddcR-Uz4MQ9EDVU-8RwRRzFszmJFrlwM,7364
22
+ punit-0.0.27.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
23
+ punit-0.0.27.dist-info/top_level.txt,sha256=LAribpo4_RB_NNSKIdVjOcjl39lVoKdb-L0BrglUeE0,6
24
+ punit-0.0.27.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (75.8.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ punit