Skip to content

Commit 1fa68d8

Browse files
migrate from unittest to pytest
1 parent a0d9fcd commit 1fa68d8

File tree

112 files changed

+8666
-8476
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+8666
-8476
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ jobs:
2323
python -m pip install --upgrade pip
2424
pip install -U coveralls
2525
pip install -e .[dev]
26-
- name: Run tests
26+
- name: Run tests with pytest
2727
run: |
28-
coverage run --branch pedantic/tests/tests_main.py
28+
pytest --doctest-modules --cov=pedantic --cov-branch --cov-report= --cov-report=term
2929
- name: Coveralls
3030
uses: coverallsapp/github-action@v2.2.3
3131
with:

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
# Changelog
2+
## Pedantic 2.4.0
3+
- migrate from unittest to pytest
4+
- exclude tests from package
5+
26
## Pedantic 2.3.3
37
- [fixed validation error message in MinLength validator](https://github.com/LostInDarkMath/pedantic-python-decorators/issues/111)
48
- removed unused scripts

docs/pedantic/decorators/fn_deco_retry.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ <h2 class="section-title" id="header-functions">Functions</h2>
7373
&gt;&gt;&gt; @retry(attempts=3, exceptions=(ValueError, TypeError))
7474
... def foo():
7575
... raise ValueError(&#39;Some error&#39;)
76-
&gt;&gt;&gt; foo()
76+
&gt;&gt;&gt; foo() # doctest: +SKIP
7777
&#34;&#34;&#34;
7878

7979
def decorator(func: C) -&gt; C:
@@ -102,7 +102,7 @@ <h2 id="example">Example</h2>
102102
<pre><code class="language-python-repl">&gt;&gt;&gt; @retry(attempts=3, exceptions=(ValueError, TypeError))
103103
... def foo():
104104
... raise ValueError('Some error')
105-
&gt;&gt;&gt; foo()
105+
&gt;&gt;&gt; foo() # doctest: +SKIP
106106
</code></pre></div>
107107
</dd>
108108
<dt id="pedantic.decorators.fn_deco_retry.retry_func"><code class="name flex">

docs/pedantic/decorators/fn_deco_validate/validators/max.html

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,12 @@ <h2 class="section-title" id="header-classes">Classes</h2>
5959
def __init__(self, value: Union[int, float], include_boundary: bool = True) -&gt; None:
6060
&#34;&#34;&#34;
6161
&gt;&gt;&gt; Max(7, True).validate(7)
62-
True
63-
&gt;&gt;&gt; Max(7, False).validate(7)
64-
False
62+
7
63+
&gt;&gt;&gt; Max(7, False).validate(7) # doctest: +IGNORE_EXCEPTION_DETAIL
64+
Traceback (most recent call last):
65+
ValidatorException: ...
6566
&gt;&gt;&gt; Max(7, False).validate(6.999)
66-
True
67+
6.999
6768
&#34;&#34;&#34;
6869
self._value = value
6970
self._include_boundary = include_boundary
@@ -80,11 +81,12 @@ <h2 class="section-title" id="header-classes">Classes</h2>
8081
<div class="desc"><p>Helper class that provides a standard way to create an ABC using
8182
inheritance.</p>
8283
<pre><code class="language-python-repl">&gt;&gt;&gt; Max(7, True).validate(7)
83-
True
84-
&gt;&gt;&gt; Max(7, False).validate(7)
85-
False
84+
7
85+
&gt;&gt;&gt; Max(7, False).validate(7) # doctest: +IGNORE_EXCEPTION_DETAIL
86+
Traceback (most recent call last):
87+
ValidatorException: ...
8688
&gt;&gt;&gt; Max(7, False).validate(6.999)
87-
True
89+
6.999
8890
</code></pre></div>
8991
<h3>Ancestors</h3>
9092
<ul class="hlist">

docs/pedantic/decorators/fn_deco_validate/validators/min.html

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,12 @@ <h2 class="section-title" id="header-classes">Classes</h2>
5959
def __init__(self, value: Union[int, float], include_boundary: bool = True) -&gt; None:
6060
&#34;&#34;&#34;
6161
&gt;&gt;&gt; Min(7, True).validate(7)
62-
True
63-
&gt;&gt;&gt; Min(7, False).validate(7)
64-
False
62+
7
63+
&gt;&gt;&gt; Min(7, False).validate(7) # doctest: +IGNORE_EXCEPTION_DETAIL
64+
Traceback (most recent call last):
65+
ValidatorException: ...
6566
&gt;&gt;&gt; Min(7, False).validate(7.001)
66-
True
67+
7.001
6768
&#34;&#34;&#34;
6869
self._value = value
6970
self._include_boundary = include_boundary
@@ -80,11 +81,12 @@ <h2 class="section-title" id="header-classes">Classes</h2>
8081
<div class="desc"><p>Helper class that provides a standard way to create an ABC using
8182
inheritance.</p>
8283
<pre><code class="language-python-repl">&gt;&gt;&gt; Min(7, True).validate(7)
83-
True
84-
&gt;&gt;&gt; Min(7, False).validate(7)
85-
False
84+
7
85+
&gt;&gt;&gt; Min(7, False).validate(7) # doctest: +IGNORE_EXCEPTION_DETAIL
86+
Traceback (most recent call last):
87+
ValidatorException: ...
8688
&gt;&gt;&gt; Min(7, False).validate(7.001)
87-
True
89+
7.001
8890
</code></pre></div>
8991
<h3>Ancestors</h3>
9092
<ul class="hlist">

docs/pedantic/index.html

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,6 @@ <h2 class="section-title" id="header-submodules">Sub-modules</h2>
7676
<dd>
7777
<div class="desc"></div>
7878
</dd>
79-
<dt><code class="name"><a title="pedantic.tests" href="tests/index.html">pedantic.tests</a></code></dt>
80-
<dd>
81-
<div class="desc"></div>
82-
</dd>
8379
<dt><code class="name"><a title="pedantic.type_checking_logic" href="type_checking_logic/index.html">pedantic.type_checking_logic</a></code></dt>
8480
<dd>
8581
<div class="desc"></div>
@@ -109,7 +105,6 @@ <h2 class="section-title" id="header-submodules">Sub-modules</h2>
109105
<li><code><a title="pedantic.helper_methods" href="helper_methods.html">pedantic.helper_methods</a></code></li>
110106
<li><code><a title="pedantic.mixins" href="mixins/index.html">pedantic.mixins</a></code></li>
111107
<li><code><a title="pedantic.models" href="models/index.html">pedantic.models</a></code></li>
112-
<li><code><a title="pedantic.tests" href="tests/index.html">pedantic.tests</a></code></li>
113108
<li><code><a title="pedantic.type_checking_logic" href="type_checking_logic/index.html">pedantic.type_checking_logic</a></code></li>
114109
</ul>
115110
</li>

docs/pedantic/mixins/with_decorated_methods.html

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,6 @@ <h3>Ancestors</h3>
117117
<li>enum.ReprEnum</li>
118118
<li>enum.Enum</li>
119119
</ul>
120-
<h3>Subclasses</h3>
121-
<ul class="hlist">
122-
<li><a title="pedantic.tests.test_with_decorated_methods.Decorators" href="../tests/test_with_decorated_methods.html#pedantic.tests.test_with_decorated_methods.Decorators">Decorators</a></li>
123-
</ul>
124120
</dd>
125121
<dt id="pedantic.mixins.with_decorated_methods.WithDecoratedMethods"><code class="flex name class">
126122
<span>class <span class="ident">WithDecoratedMethods</span></span>
@@ -152,7 +148,7 @@ <h3>Subclasses</h3>
152148
... def m3(self) -&gt; None:
153149
... print(&#39;bar&#39;)
154150
&gt;&gt;&gt; instance = MyClass()
155-
&gt;&gt;&gt; instance.get_decorated_functions()
151+
&gt;&gt;&gt; instance.get_decorated_functions() # doctest: +SKIP
156152
{
157153
&lt;Decorators.FOO: &#39;_foo&#39;&gt;: {
158154
&lt;bound method MyClass.m1 of &lt;__main__.MyClass object at 0x7fea7a6e2610&gt;&gt;: 42,
@@ -203,7 +199,7 @@ <h2 id="example">Example</h2>
203199
... def m3(self) -&gt; None:
204200
... print('bar')
205201
&gt;&gt;&gt; instance = MyClass()
206-
&gt;&gt;&gt; instance.get_decorated_functions()
202+
&gt;&gt;&gt; instance.get_decorated_functions() # doctest: +SKIP
207203
{
208204
&lt;Decorators.FOO: '_foo'&gt;: {
209205
&lt;bound method MyClass.m1 of &lt;__main__.MyClass object at 0x7fea7a6e2610&gt;&gt;: 42,

pedantic/decorators/fn_deco_retry.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def retry(
3131
>>> @retry(attempts=3, exceptions=(ValueError, TypeError))
3232
... def foo():
3333
... raise ValueError('Some error')
34-
>>> foo()
34+
>>> foo() # doctest: +SKIP
3535
"""
3636

3737
def decorator(func: C) -> C:

pedantic/decorators/fn_deco_validate/validators/max.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@ class Max(Validator):
88
def __init__(self, value: Union[int, float], include_boundary: bool = True) -> None:
99
"""
1010
>>> Max(7, True).validate(7)
11-
True
12-
>>> Max(7, False).validate(7)
13-
False
11+
7
12+
>>> Max(7, False).validate(7) # doctest: +IGNORE_EXCEPTION_DETAIL
13+
Traceback (most recent call last):
14+
ValidatorException: ...
1415
>>> Max(7, False).validate(6.999)
15-
True
16+
6.999
1617
"""
1718
self._value = value
1819
self._include_boundary = include_boundary

pedantic/decorators/fn_deco_validate/validators/min.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@ class Min(Validator):
88
def __init__(self, value: Union[int, float], include_boundary: bool = True) -> None:
99
"""
1010
>>> Min(7, True).validate(7)
11-
True
12-
>>> Min(7, False).validate(7)
13-
False
11+
7
12+
>>> Min(7, False).validate(7) # doctest: +IGNORE_EXCEPTION_DETAIL
13+
Traceback (most recent call last):
14+
ValidatorException: ...
1415
>>> Min(7, False).validate(7.001)
15-
True
16+
7.001
1617
"""
1718
self._value = value
1819
self._include_boundary = include_boundary

0 commit comments

Comments
 (0)