generated from ken-morel/pip-package-template-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
110 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,8 +17,6 @@ jobs: | |
fail-fast: false | ||
matrix: | ||
python-version: | ||
- "3.8" | ||
- "3.9" | ||
- "3.10" | ||
- "3.11" | ||
- "3.12" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pytest --cov --cov-report term-missing:skip-covered |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
typeMatch vs isinstance on int:True 0.26837916ms | ||
typeMatch vs isinstance on int:False 0.24146669ms | ||
typeMatch on dict[str, int]*50:True 29.45430688ms | ||
typeMatch on dict[str, int]*50:False 5.970363880000001ms | ||
Cast str->int: 2.92456138ms | ||
Cast complex->int | str: 0.12061774399999999ms | ||
Cast dict[int,list[str]*10]*10->dict[str,tuple[float]]: 2.7908898460000002ms | ||
typeMatch vs isinstance on int:True 1.2414197ms | ||
typeMatch vs isinstance on int:False 2.8583822ms | ||
typeMatch on dict[str, int]*50:True 208.6217113ms | ||
typeMatch on dict[str, int]*50:False 16.4641389ms | ||
Cast str->int: 7.2549127ms | ||
Cast complex->int | str: 0.27592566ms | ||
Cast dict[int,list[str]*10]*10->dict[str,tuple[float]]: 9.29763984ms |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import pyoload | ||
|
||
|
||
assert pyoload.__version__ == '2.0.0' | ||
|
||
|
||
errors = ( | ||
pyoload.AnnotationError, | ||
pyoload.AnnotationErrors, | ||
pyoload.InternalAnnotationError, | ||
pyoload.CastingError, | ||
pyoload.OverloadError, | ||
pyoload.AnnotationResolutionError, | ||
) | ||
|
||
|
||
def test_errors(): | ||
for err in errors: | ||
try: | ||
raise err() | ||
except err: | ||
pass | ||
except Exception: | ||
raise | ||
else: | ||
raise Exception() | ||
|
||
pyoload.PyoloadAnnotation() | ||
v = pyoload.Values((1, 2, 3)) | ||
v(2) | ||
str(v) | ||
|
||
assert pyoload.get_name(test_errors).endswith('test_errors') | ||
|
||
class Custom(pyoload.Check): | ||
def __call__(self, a, b): | ||
assert a == b | ||
|
||
@pyoload.annotate | ||
def foo(a: pyoload.Checks(Custom=3)): | ||
pass | ||
|
||
try: | ||
foo(2) | ||
except pyoload.AnnotationError: | ||
foo(3) | ||
else: | ||
raise Exception() | ||
|
||
try: | ||
pyoload.Check.register('Custom') | ||
except pyoload.Check.CheckNameAlreadyExistsError: | ||
pass | ||
else: | ||
raise Exception() | ||
|
||
@pyoload.Check.register('c2 c3') | ||
def _(a, b): | ||
assert a == b | ||
|
||
@pyoload.annotate | ||
def foo(a: pyoload.Checks(c2=3, c3=3)): | ||
pass | ||
|
||
try: | ||
foo(2) | ||
except pyoload.AnnotationErrors: | ||
foo(3) | ||
else: | ||
raise Exception() | ||
|
||
try: | ||
@pyoload.annotate | ||
def bar(c: pyoload.Checks(rub=3)): | ||
raise Exception(c) | ||
|
||
bar(NotImplemented) | ||
except pyoload.Check.CheckDoesNotExistError: | ||
pass | ||
|
||
for name, check in pyoload.Check.checks_list.items(): | ||
try: | ||
if pyoload.get_name(check).split('.')[0] == 'tests': | ||
continue | ||
pyoload.Checks(**{name: NotImplemented})(24) | ||
except pyoload.Check.CheckError: | ||
pass | ||
else: | ||
raise Exception(name, check) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters