packages
bundle
hydrox
hydrox
helpers
hypothesis
typing
jugulis
···
7
7
from pytest import hookimpl
8
8
from hypothesis import HealthCheck
9
9
from hypothesis import settings
10
10
-
from functools import partial
11
10
12
11
# Adapted From: https://docs.pytest.org/en/stable/example/simple.html
13
12
# And: https://github.com/pytest-dev/pytest/issues/5024#issuecomment-2078698395
···
551
551
arguments = self._filter_params(other.params, click.Argument)
552
552
return (
553
553
all(
554
554
-
self._equal(
554
554
+
False
555
555
+
for index, param in enumerate(self._arguments)
556
556
+
if not self._equal(
555
557
param,
556
558
arguments[index],
557
559
obj_name=f"{self.name}:{param.name}",
558
560
other_name=f"{other.name}:{param.name}",
559
561
)
560
560
-
for index, param in enumerate(self._arguments)
561
562
)
562
563
and all(
563
563
-
self._equal(
564
564
+
False
565
565
+
for index, param in enumerate(self._options)
566
566
+
if not self._equal(
564
567
param,
565
568
options[index],
566
569
obj_name=f"{self.name}:{param.name}",
567
570
other_name=f"{other.name}:{param.name}",
568
571
)
569
569
-
for index, param in enumerate(self._options)
570
572
)
571
573
and self._equal(
572
574
self.func,
···
576
578
obj_name=f"self: {self.name}",
577
579
other_name=f"other: {other.name}",
578
580
)
581
581
+
# and all(
582
582
+
# v._equals(other.commands[k], *ignores) if k in other.commands else False
583
583
+
# for k, v in self.children.items()
584
584
+
# )
579
585
and all(
580
580
-
v._equals(other.commands[k], *ignores) if k in other.commands else False
586
586
+
False
581
587
for k, v in self.children.items()
588
588
+
if not (
589
589
+
(k in other.commands) and v._equals(other.commands[k], *ignores)
590
590
+
)
582
591
)
583
592
)
584
593
···
589
598
return (
590
599
self.equals(other)
591
600
and self._func == other.callback
601
601
+
# and all(
602
602
+
# (v._func == other.commands[k].callback)
603
603
+
# if k in other.commands
604
604
+
# else False
605
605
+
# for k, v in self.children.items()
606
606
+
# )
592
607
and all(
593
593
-
(v._func == other.commands[k].callback)
594
594
-
if k in other.commands
595
595
-
else False
608
608
+
False
596
609
for k, v in self.children.items()
610
610
+
if not (
611
611
+
(k in other.commands) and (v._func == other.commands[k].callback)
612
612
+
)
597
613
)
598
614
)
599
615
···
3
3
import collections.abc as abc
4
4
from .decorator import Decorator
5
5
from .helpers import zipsuppress
6
6
-
from contextlib import suppress
7
6
from functools import partial, wraps, cache as defcache
8
7
from inspect import isclass, getattr_static
9
9
-
from rich import print
10
10
-
from rich.rule import Rule
11
8
12
9
sentinel = object()
13
10
···
15
15
getmodule,
16
16
)
17
17
from itertools import permutations
18
18
-
from more_itertools import powerset, collapse
18
18
+
from more_itertools import powerset
19
19
20
20
BString: typing.TypeAlias = str | bytes | bytearray
21
21
···
104
104
105
105
class FlattenMeta(type):
106
106
def __call__(self, *iterables, use=builtins.tuple(), levels=None, current_level=0):
107
107
-
if levels is None:
108
108
-
yield from collapse(use or iterables)
109
107
for iterable in use or iterables:
110
108
if isinstance(iterable, Collection) and (
111
109
(levels is None) or (current_level < levels)
···
76
76
try:
77
77
hash(apply_kwargs(strat).example())
78
78
except TypeError as e:
79
79
-
if not "unhashable type:" in str(e):
79
79
+
if "unhashable type:" not in str(e):
80
80
raise e
81
81
except AttributeError as e:
82
82
if str(e) != "'NoneType' object has no attribute 'example'":
···
9
9
import gc
10
10
import inspect
11
11
import operator
12
12
-
import os
13
12
import re
14
13
import sys
15
14
···
21
20
from abc import ABCMeta
22
21
from contextlib import suppress
23
22
from collections import defaultdict
24
24
-
from cytoolz.itertoolz import unique, partition
25
25
-
from cytoolz.dicttoolz import keymap, valmap
23
23
+
from cytoolz.dicttoolz import keymap
24
24
+
from cytoolz.itertoolz import unique
26
25
from functools import partial, reduce, cache as defcache
27
26
from inspect import Parameter
28
28
-
from inspect import getmro, stack, FrameInfo
29
29
-
from random import randint, sample
30
30
-
from rich import print
31
31
-
from rich.traceback import Traceback
32
32
-
from rich.rule import Rule
33
33
-
from rich.pretty import pprint
27
27
+
from inspect import getmro, stack
28
28
+
from more_itertools import partition
29
29
+
from random import randint
34
30
from rich.table import Table
35
31
from rich.console import Console
36
32
from warnings import warn
···
445
441
super().__setitem__(get_name(key), value)
446
442
447
443
def _process_dict(self, other):
448
448
-
return {get_name(k): v for k, v in other.items()}
444
444
+
return keymap(get_name, other)
449
445
450
446
def copy(self): # don't delegate w/ super - dict.copy() -> dict :(
451
447
return self.__class__(base=self)
···
1032
1028
try:
1033
1029
return obj.__genericsupertype__()
1034
1030
except TypeError as e:
1035
1035
-
if not "missing 1 required positional argument: 'cls'" in str(e):
1031
1031
+
if "missing 1 required positional argument: 'cls'" not in str(e):
1036
1032
raise e
1037
1033
return obj.__genericsupertype__(obj)
1038
1034
···
1054
1050
format_args(
1055
1051
dict,
1056
1052
[
1057
1057
-
unionize(types.UnionType, keymap(inner, obj)),
1058
1058
-
unionize(types.UnionType, valmap(inner, obj)),
1053
1053
+
unionize(types.UnionType, [inner(k) for k in obj.keys()]),
1054
1054
+
unionize(types.UnionType, [inner(v) for v in obj.values()]),
1059
1055
],
1060
1056
)
1061
1057
)
···
1962
1958
alias_result.__hash_value__ = reducehash(
1963
1959
origin,
1964
1960
(
1965
1965
-
tuple(arg.items())
1961
1961
+
arg.items()
1966
1962
if isinstance(arg, abc.Mapping)
1967
1967
-
else tuple(arg)
1968
1968
-
if isinstance(arg, list)
1969
1963
else arg
1970
1964
for arg in args
1971
1965
),
···
3
3
from hydrox.hypothesis import Args, AllGeneric, HTGenericAlias
4
4
import hydrox.typing as ht
5
5
import hydrox.helpers as hh
6
6
-
import typing
7
7
-
import collections.abc as abc
8
8
-
from hypothesis import given, strategies as st, example
9
9
-
from rich.pretty import pprint
6
6
+
from hypothesis import given
10
7
11
8
# @given(
12
9
# generic=...,
···
1
1
-
# import hydrox.typing as ht
2
2
-
# from hydrox.helpers import superpowerset, flatten
3
3
-
# from hypothesis import given, strategies as st, example
4
4
-
# from random import randint, randrange
5
5
-
# from collections import defaultdict
6
6
-
# from pytest import mark
7
7
-
8
8
-
# all_attrs = tuple(superpowerset("in", "is", "generic", "ht", "only"))
9
9
-
10
10
-
# ht_generic_attrs = []
11
11
-
# no_ht_generic_attrs = []
12
12
-
# for p in all_attrs:
13
13
-
# if p:
14
14
-
# if "ht" in p or "generic" in p:
15
15
-
# ht_generic_attrs.append(p)
16
16
-
# else:
17
17
-
# no_ht_generic_attrs.append("".join(p))
18
18
-
19
19
-
# ends_with_in_is_attrs = []
20
20
-
# in_is_is_in_attrs = []
21
21
-
# usable_attrs = []
22
22
-
# only_attrs = []
23
23
-
# for p in ht_generic_attrs:
24
24
-
# length = len(p)
25
25
-
# attr = "".join(p)
26
26
-
# if length > 1:
27
27
-
# if p[-1] in ("in", "is"):
28
28
-
# ends_with_in_is_attrs.append(attr)
29
29
-
# continue
30
30
-
# if "inis" in attr or "isin" in attr:
31
31
-
# in_is_is_in_attrs.append(attr)
32
32
-
# continue
33
33
-
# current_key = "global"
34
34
-
# new_attrs = defaultdict(str)
35
35
-
# for a in filter(
36
36
-
# None, flatten(part.partition("is") for part in attr.partition("in"))
37
37
-
# ):
38
38
-
# if a == "in":
39
39
-
# current_key = "in"
40
40
-
# continue
41
41
-
# if a == "is":
42
42
-
# current_key = "is"
43
43
-
# continue
44
44
-
# new_attrs[current_key] = a
45
45
-
# global_attr = new_attrs["global"]
46
46
-
# broken = False
47
47
-
# for i in ("in", "is"):
48
48
-
# i_attr = new_attrs["global"] + new_attrs[i]
49
49
-
# if i_attr and not ("ht" in i_attr or "generic" in i_attr):
50
50
-
# only_attrs.append(attr)
51
51
-
# broken = True
52
52
-
# break
53
53
-
# if broken:
54
54
-
# continue
55
55
-
# usable_attrs.append(p)
56
56
-
57
57
-
# multiple_in_is_attrs = []
58
58
-
# for p in usable_attrs:
59
59
-
# length = len(p)
60
60
-
# if length > 1:
61
61
-
# in_is = "in" if randint(0, 1) else "is"
62
62
-
# p = list(p)
63
63
-
# for i in range(length):
64
64
-
# pos = randrange(1, length)
65
65
-
# p.insert(pos, in_is)
66
66
-
# multiple_in_is_attrs.append("".join(p))
67
67
-
68
68
-
# is_in_attrs = []
69
69
-
# no_is_in_attrs = []
70
70
-
# for p in usable_attrs:
71
71
-
# attr = "".join(p)
72
72
-
# if "in" in p or "is" in p:
73
73
-
# is_in_attrs.append(attr)
74
74
-
# else:
75
75
-
# no_is_in_attrs.append(attr)
76
76
-
77
77
-
78
78
-
# class TestIsInMROSubclassGetter:
79
79
-
# @given(attr=st.sampled_from(is_in_attrs))
80
80
-
# @example(attr="genericinhtisonly")
81
81
-
# def test_is_in(self, attr):
82
82
-
# only = {}
83
83
-
# getters = {}
84
84
-
# only["in"], getters["in"], only["is"], getters["is"] = (
85
85
-
# ht.isinmrosubclass.getter(attr)
86
86
-
# )
87
87
-
# current_key = "global"
88
88
-
# new_attrs = defaultdict(str)
89
89
-
# for a in filter(
90
90
-
# None, flatten(part.partition("is") for part in attr.partition("in"))
91
91
-
# ):
92
92
-
# if a == "in":
93
93
-
# current_key = "in"
94
94
-
# if a == "is":
95
95
-
# current_key = "is"
96
96
-
# new_attrs[current_key] = a
97
97
-
# for i in ("in", "is"):
98
98
-
# i_attr = new_attrs["global"] + new_attrs[i]
99
99
-
# if "only" in i_attr:
100
100
-
# assert only[i], i
101
101
-
# if "ht" in i_attr:
102
102
-
# if "generic" in i_attr:
103
103
-
# assert getters[i] == ht.get_all_ht_generics, i
104
104
-
# else:
105
105
-
# assert getters[i] == ht.HTGenerics.__getitem__, i
106
106
-
# elif "generic" in i_attr:
107
107
-
# assert getters[i] == ht.get_all_generics, i
108
108
-
# else:
109
109
-
# assert getters[i] is None
110
110
-
111
111
-
# @given(attr=st.sampled_from(no_is_in_attrs))
112
112
-
# def test_no_is_in(self, attr):
113
113
-
# inmro_only, inmro_getter, issubclass_only, issubclass_getter = (
114
114
-
# ht.isinmrosubclass.getter(attr)
115
115
-
# )
116
116
-
# if "only" in attr:
117
117
-
# assert inmro_only and issubclass_only
118
118
-
# if "ht" in attr:
119
119
-
# if "generic" in attr:
120
120
-
# assert inmro_getter == issubclass_getter == ht.get_all_ht_generics
121
121
-
# else:
122
122
-
# assert inmro_getter == issubclass_getter == ht.HTGenerics.__getitem__
123
123
-
# else:
124
124
-
# assert inmro_getter == issubclass_getter == ht.get_all_generics
125
125
-
126
126
-
# @given(attr=st.sampled_from(in_is_is_in_attrs))
127
127
-
# def test_in_is_is_in(self, attr):
128
128
-
# try:
129
129
-
# ht.isinmrosubclass.getter(attr)
130
130
-
# except AttributeError as e:
131
131
-
# assert '"in" and "is" cannot be right next to each other' in str(e)
132
132
-
# else:
133
133
-
# assert False
134
134
-
135
135
-
# @given(attr=st.sampled_from(no_ht_generic_attrs))
136
136
-
# def test_no_ht_generic(self, attr):
137
137
-
# try:
138
138
-
# ht.isinmrosubclass.getter(attr)
139
139
-
# except AttributeError as e:
140
140
-
# assert 'A combination of "in", "is", "only", "ht", and "generic"' in str(e)
141
141
-
# else:
142
142
-
# assert False
143
143
-
144
144
-
# @given(attr=st.sampled_from(ends_with_in_is_attrs))
145
145
-
# def test_starts_ends_with_in_is(self, attr):
146
146
-
# try:
147
147
-
# ht.isinmrosubclass.getter(attr)
148
148
-
# except AttributeError as e:
149
149
-
# assert 'cannot end with "in" or "is"' in str(e)
150
150
-
# else:
151
151
-
# assert False
152
152
-
153
153
-
# @given(attr=st.sampled_from(multiple_in_is_attrs))
154
154
-
# def test_multiple_in_is(self, attr):
155
155
-
# try:
156
156
-
# ht.isinmrosubclass.getter(attr)
157
157
-
# except AttributeError as e:
158
158
-
# assert (
159
159
-
# '"in" and "is" cannot be used more than once in attribute name'
160
160
-
# in str(e)
161
161
-
# )
162
162
-
# else:
163
163
-
# assert False
164
164
-
165
165
-
# @given(attr=st.sampled_from(only_attrs))
166
166
-
# @example(attr="onlyisht")
167
167
-
# def test_only(self, attr):
168
168
-
# try:
169
169
-
# ht.isinmrosubclass.getter(attr)
170
170
-
# except AttributeError as e:
171
171
-
# assert 'A combination of "only", "ht", and "generic"' in str(e)
172
172
-
# else:
173
173
-
# assert False
···
1
1
-
# from hydrox.hypothesis import Data, Args, HTGenericAlias
2
2
-
# from hydrox.typing.generic import some
3
3
-
# from hydrox.helpers import Collection
4
4
-
# import hydrox.typing as ht
5
5
-
# import typing
6
6
-
# from hypothesis import given, strategies as st
7
7
-
# from collections import namedtuple
8
8
-
9
9
-
# Max = namedtuple("Max", "max")
10
10
-
# minimum = 0
11
11
-
12
12
-
13
13
-
# # TODO: Simplify.
14
14
-
# class TestSome:
15
15
-
# @given(data=..., generic=..., args=...)
16
16
-
# def test_cls(self, data: Data, generic: HTGenericAlias, args: Args):
17
17
-
# args_length = len(args)
18
18
-
# maximum = data.draw(
19
19
-
# st.integers(
20
20
-
# min_value=minimum,
21
21
-
# max_value=ht.get_generic_subscription_size(generic, rand=True),
22
22
-
# ).filter(lambda i: i < args_length)
23
23
-
# )
24
24
-
# some_args = some(ht.format_args(generic.__recreate__(maximum), args))
25
25
-
# some_length = len(some_args)
26
26
-
# assert some_length == maximum
27
27
-
# assert all(a in args for a in some_args)
28
28
-
# assert tuple(some_args) != tuple(args)
29
29
-
30
30
-
# @given(data=..., generic=..., args=..., maximum=st.integers(min_value=minimum))
31
31
-
# def test_maximum(self, data: Data, generic: HTGenericAlias, args: Args, maximum):
32
32
-
# args_length = len(args)
33
33
-
# maximum = data.draw(
34
34
-
# st.integers(
35
35
-
# min_value=minimum,
36
36
-
# max_value=ht.get_generic_subscription_size(generic, rand=True),
37
37
-
# ).filter(lambda i: i < args_length)
38
38
-
# )
39
39
-
# some_args = some(ht.format_args(generic, args), maximum=maximum)
40
40
-
# some_length = len(some_args)
41
41
-
# assert some_length == maximum
42
42
-
# assert all(a in args for a in some_args)
43
43
-
# assert tuple(some_args) != tuple(args)
44
44
-
45
45
-
# @given(data=..., iterable=...)
46
46
-
# def test_iterable(self, data: Data, iterable: Collection[typing.Any]):
47
47
-
# maximum = data.draw(st.integers(min_value=minimum, max_value=len(iterable) - 1))
48
48
-
# some_args = some(Max(maximum), iterable)
49
49
-
# some_length = len(some_args)
50
50
-
# assert some_length == maximum
51
51
-
# assert all(a in iterable for a in some_args)
52
52
-
# assert tuple(some_args) != tuple(iterable)
53
53
-
54
54
-
# @given(data=..., iterable=...)
55
55
-
# def test_maximum_iterable(self, data: Data, iterable: Collection[typing.Any]):
56
56
-
# maximum = data.draw(st.integers(min_value=minimum, max_value=len(iterable) - 1))
57
57
-
# some_args = some(None, iterable, maximum)
58
58
-
# some_length = len(some_args)
59
59
-
# assert some_length == maximum
60
60
-
# assert all(a in iterable for a in some_args)
61
61
-
# assert tuple(some_args) != tuple(iterable)
···
11
11
)
12
12
import hydrox.typing as ht
13
13
from hypothesis import given, strategies as st, example, assume
14
14
-
from pytest import mark
15
14
16
15
17
16
class TestSetSubclass:
···
1
1
-
import os
2
2
-
3
3
-
4
1
class TestTests:
5
2
def test_tests(self):
6
3
# raise Exception(os.environ["PYTEST_CURRENT_TEST"])
···
1
1
-
import hydrox.typing as ht, typing
1
1
+
import hydrox.typing as ht
2
2
+
import typing
2
3
from hydrox.hypothesis import AllGeneric, Data, HTGeneric, Args, SubArgs, subgen_strat
3
4
from hypothesis import assume, given, strategies as st, example
4
5
···
4
4
import typing
5
5
6
6
from ..helpers import BString, Collection, flatten, infm1, aleph
7
7
-
from ..typing.generic import Annotation, Generalize, GenericMetas, Generics
7
7
+
from ..typing.generic import Annotation, Generalize, Generics
8
8
from ..typing.generic import (
9
9
annotation_is_not_generic,
10
10
anything,
···
30
30
supertype,
31
31
)
32
32
from ..variables import conversion_table
33
33
-
from contextlib import suppress
34
34
-
from cytoolz.itertoolz import unique, partition
33
33
+
from cytoolz.itertoolz import unique
34
34
+
from more_itertools import partition
35
35
36
36
37
37
@Generalize
···
1
1
-
import collections.abc as abc, typing
2
2
-
from warnings import warn
3
3
-
from functools import cache as defcache
4
4
-
from hydrox.helpers import cache, reversecut
5
1
from hydrox.typing import (
6
6
-
_scoresubclass,
7
7
-
generalize,
8
8
-
generic_flatten,
9
2
GenericMeta,
10
10
-
get_origin,
11
3
has_custom_init,
12
12
-
left_right_collection_check,
13
13
-
partition_ellipsis,
14
14
-
score,
15
15
-
scoreargs,
16
16
-
scoremro,
17
17
-
tryinmro,
18
18
-
tryinmrosubclass,
19
19
-
trysubclass,
20
20
-
TypeWarning,
21
4
)
22
22
-
from contextlib import contextmanager
23
23
-
from rich.rule import Rule
24
5
25
6
26
7
# NOTE: Can't cache this; booleans, floats, strings, and integers sometimes have the same hash values.
···
1
1
-
import hydrox.helpers as hh
2
2
-
3
1
# assert +
4
2
# assert -
5
3
# assert *
···
44
44
func = processor(func)
45
45
self.__func__ = func
46
46
47
47
+
def __eq__(self, other: Deino):
48
48
+
return (
49
49
+
isinstance(other, self.__class__)
50
50
+
and (self.__func__ == other.__func__)
51
51
+
and (self.__cache_kwargs__ == other.__cache_kwargs__)
52
52
+
) or NotImplemented
53
53
+
54
54
+
def __hash__(self):
55
55
+
return ht.reducehash(self.__func__, self.__cache_kwargs__.items())
56
56
+
47
57
def __process__(self, func):
48
58
func.__signature__ = ht.signature(func)
49
59
func.__spec__ = getfullargspec(func)
···
1
1
-
import collections.abc as abc, hydrox.typing as ht
1
1
+
import hydrox.typing as ht
2
2
from .variables import sentinel
3
3
-
from contextlib import suppress
4
3
from functools import cache as defcache, partial
5
4
from hydrox.typing import format_args, generalize, get_args, get_origin, scoreinstance
6
6
-
from hydrox.helpers import zipsuppress, CacheError, _make_key
5
5
+
from hydrox.helpers import zipsuppress
7
6
from inspect import FullArgSpec, Parameter, Signature
8
7
from itertools import zip_longest
9
8
from types import MappingProxyType
10
9
from typing import Any, Optional, TypeVar
11
11
-
from rich import print
12
12
-
from rich.rule import Rule
13
13
-
from rich.pretty import pprint
14
10
15
11
16
12
@defcache
···
1
1
from hydrox.helpers import as_decorator, query, cache_get
2
2
+
from hydrox.typing import reducehash
2
3
from .deino import Deino, format_message
3
3
-
from collections import defaultdict, namedtuple
4
4
+
from collections import defaultdict
4
5
from functools import partial
5
6
from rich.table import Table
6
7
from rich.console import Console
7
7
-
from inspect import isclass
8
8
9
9
console = Console()
10
10
···
42
42
self.append(
43
43
Deino(func, self.__cache__, evolved=True, **self.__cache_kwargs__)
44
44
)
45
45
+
46
46
+
def __hash__(self):
47
47
+
return reducehash(self)
45
48
46
49
def __score__(self, *args, **kwargs):
47
50
return {func: func.__score__(*args, **kwargs) for func in self}
···
2
2
from hydrox.helpers import as_decorator, query
3
3
from .functions import process_key
4
4
from .hydreigon import Hydreigon
5
5
-
from rich.pretty import pprint
6
5
from collections import defaultdict
7
6
8
7
···
1
1
+
from pytest import fixture
2
2
+
from jugulis import Hydreigon
3
3
+
4
4
+
5
5
+
@fixture
6
6
+
def f():
7
7
+
@Hydreigon
8
8
+
def f(a: int, /) -> int:
9
9
+
return 0
10
10
+
11
11
+
@f.roar
12
12
+
def f(a: int, /, b: int) -> int:
13
13
+
return 1
14
14
+
15
15
+
@f.roar
16
16
+
def f(a: int, /, b: int, *c) -> int:
17
17
+
return 2
18
18
+
19
19
+
@f.roar
20
20
+
def f(a: int, /, b: int, *c, d: int) -> int:
21
21
+
return 3
22
22
+
23
23
+
@f.roar
24
24
+
def f(a: int, /, b: int, *c, d: int, **e) -> int:
25
25
+
return 4
26
26
+
27
27
+
return f
28
28
+
29
29
+
30
30
+
@fixture
31
31
+
def g():
32
32
+
@Hydreigon
33
33
+
def g(a: int, /) -> int:
34
34
+
return 0
35
35
+
36
36
+
@g.roar
37
37
+
def g(a: int, /, b: int) -> int:
38
38
+
return 1
39
39
+
40
40
+
@g.roar
41
41
+
def g(a: int, /, b: int, *c) -> int:
42
42
+
return 2
43
43
+
44
44
+
@g.roar
45
45
+
def g(a: int, /, b: int, *c, d: int) -> int:
46
46
+
return 3
47
47
+
48
48
+
@g.roar
49
49
+
def g(a: int, /, b: int, *c, d: int, **e) -> int:
50
50
+
return 4
51
51
+
52
52
+
return g
···
1
1
-
from jugulis import Hydreigon, AmbiguityError
2
2
-
from pytest import fixture
1
1
+
from jugulis import AmbiguityError
3
2
4
3
5
4
class TestHydreigon:
6
6
-
@fixture
7
7
-
def f(self):
8
8
-
@Hydreigon
9
9
-
def f(a: int, /) -> int:
10
10
-
return 0
11
11
-
12
12
-
@f.roar
13
13
-
def f(a: int, /, b: int) -> int:
14
14
-
return 1
15
15
-
16
16
-
@f.roar
17
17
-
def f(a: int, /, b: int, *c) -> int:
18
18
-
return 2
19
19
-
20
20
-
@f.roar
21
21
-
def f(a: int, /, b: int, *c, d: int) -> int:
22
22
-
return 3
23
23
-
24
24
-
@f.roar
25
25
-
def f(a: int, /, b: int, *c, d: int, **e) -> int:
26
26
-
return 4
27
27
-
28
28
-
return f
29
29
-
30
5
def test_positional_only(self, f):
31
6
assert f(0) == 0
32
7
···
1
1
+
from pytest import fixture
2
2
+
from jugulis import Jugulis
3
3
+
from operator import attrgetter
4
4
+
5
5
+
6
6
+
# TODO: Test when the functions are being added in an alternating pattern.
7
7
+
class TestJugulis:
8
8
+
@fixture
9
9
+
def jugulis(self):
10
10
+
return Jugulis()
11
11
+
12
12
+
def test_one_function(self, jugulis, f):
13
13
+
for func in map(attrgetter("__func__"), f):
14
14
+
jugulis(func)
15
15
+
16
16
+
assert jugulis == {"f": f}
17
17
+
18
18
+
def test_two_functions(self, jugulis, f, g):
19
19
+
for func in map(attrgetter("__func__"), f + g):
20
20
+
jugulis(func)
21
21
+
22
22
+
assert jugulis == {"f": f, "g": g}
···
1
1
# TODO: Create `bound` examples.
2
2
3
3
-
import hydrox.typing as ht, collections.abc as abc, typing
3
3
+
import hydrox.typing as ht
4
4
+
import collections.abc as abc
5
5
+
import typing
4
6
from hydrox.hypothesis import (
5
7
Data,
6
8
bound_type_var_strat,
···
1
1
-
import hydrox.typing as ht, typing, collections.abc
1
1
+
import hydrox.typing as ht
2
2
+
import typing
3
3
+
import collections.abc
2
4
from hydrox.hypothesis import (
3
5
AllGeneric,
4
6
HTGeneric,
5
7
Data,
6
8
subgen_strat,
7
9
subarg_strat,
8
8
-
arg_strat,
9
10
)
10
10
-
from hypothesis import assume, strategies as st, given, example
11
11
+
from hypothesis import strategies as st, given, example
11
12
from jugulis import scorefunction
12
13
from inspect import Signature, FullArgSpec, getfullargspec
13
13
-
from parametrized import parametrized
14
14
from pytest import fixture
15
15
16
16
···
1
1
+
from jugulis import Deino
2
2
+
3
3
+
4
4
+
def test(): ...
5
5
+
6
6
+
7
7
+
assert Deino(test) == Deino(test)
8
8
+
9
9
+
from jugulis import Hydreigon
10
10
+
11
11
+
assert Hydreigon(test) == Hydreigon(test)