PK!lXffLICENSECopyright (c) 2018 macheins Provided that these terms and disclaimer and all copyright notices are retained or reproduced in an accompanying document, permission is granted to deal in this work without restriction, including un- limited rights to use, publicly perform, distribute, sell, modify, merge, give away, or sublicence. This work is provided "AS IS" and WITHOUT WARRANTY of any kind, to the utmost extent permitted by applicable law, neither express nor implied; without malicious intent or gross negligence. In no event may a licensor, author or contributor be held liable for indirect, direct, other damage, loss, or other issues arising in any way out of dealing in the work, even if advised of the possibility of such damage or existence of a defect, except proven that it results out of said person's immediate fault when using the work as intended. PK!`^hypothesis_jsonrpc/__init__.pyimport pkg_resources try: __version__ = pkg_resources.get_distribution(__name__).version except pkg_resources.DistributionNotFound: # pragma: no cover pass PK!hypothesis_jsonrpc/py.typedPK!( hypothesis_jsonrpc/strategies.pyfrom typing import Dict, List, Union import hypothesis.strategies as hs import hypothesis_json.strategies as js from hypothesis.searchstrategy import SearchStrategy from hypothesis_json._utils import validate_bool from hypothesis_json.errors import InvalidArgument, InvalidArgumentValue from hypothesis_json.typing import JSON def requests( *, infs: bool = False, nan: bool = False, max_leaves: int = 50 ) -> SearchStrategy[JSON]: """Strategy to generate random valid JSON-RPC 2.0 requests.""" return hs.composite(_requests)(infs=infs, nan=nan, max_leaves=max_leaves) def _ensure_structure(j: JSON) -> Union[List[JSON], Dict[str, JSON]]: if not isinstance(j, (list, dict)): j = [j] return j def _requests(draw, *, infs, nan, max_leaves): # type: ignore validate_bool(infs) validate_bool(nan) if not isinstance(max_leaves, int): raise InvalidArgument() if max_leaves < 0: raise InvalidArgumentValue() req = draw( hs.fixed_dictionaries( { "jsonrpc": hs.just("2.0"), "id": js.primitives( default=False, null=True, integers=True, strings=True ), "method": js.primitives(default=False, strings=True), "params": js.jsons(infs=infs, nan=nan, max_leaves=max_leaves), } ) ) if isinstance(req["id"], int): if draw(hs.booleans()): req["id"] = float(req["id"]) elif req["id"] is None: del req["id"] req["params"] = _ensure_structure(req["params"]) if not req["params"]: if draw(hs.booleans()): del req["params"] return req def invalid_requests( *, infs: bool = False, nan: bool = False, max_leaves: int = 10 ) -> SearchStrategy[JSON]: """Strategy to generate invalid JSON-RPC 2.0 requests by mutating valid requests.""" return hs.composite(_invalid_requests)( infs=infs, nan=nan, max_leaves=max_leaves ) def _invalid_requests(draw, infs, nan, max_leaves): # type: ignore validate_bool(infs) validate_bool(nan) if not isinstance(max_leaves, int): raise InvalidArgument() if max_leaves < 0: raise InvalidArgumentValue() req = draw(requests(infs=infs, nan=nan, max_leaves=max_leaves)) omit = object() bad = { # type: ignore "jsonrpc": hs.one_of( hs.just(omit), hs.sampled_from( [ 2, 2.0, "2", "2.", "2.00", "02.0", "2,0", "20", " 2.0", "2.0 ", "2 0", "2. 0", "2 .0", ["2.0"], {"2.0": "2.0"}, ] ), js.jsons(infs=infs, nan=nan, max_leaves=max_leaves).filter( lambda j: j != "2.0" ), ), "id": js.jsons( infs=infs, nan=nan, integers=False, strings=False, max_leaves=max_leaves, ), "method": hs.one_of( hs.just(omit), js.jsons( infs=infs, nan=nan, strings=False, max_leaves=max_leaves ), ), "params": js.primitives(infs=infs, nan=nan), } keys = draw( hs.lists( hs.sampled_from(sorted(req.keys())), min_size=1, max_size=len(req), unique=True, ) ) for key in keys: req[key] = draw(bad[key]) if req[key] is omit: del req[key] return req PK!lXff*hypothesis_jsonrpc-2.0.0.dist-info/LICENSECopyright (c) 2018 macheins Provided that these terms and disclaimer and all copyright notices are retained or reproduced in an accompanying document, permission is granted to deal in this work without restriction, including un- limited rights to use, publicly perform, distribute, sell, modify, merge, give away, or sublicence. This work is provided "AS IS" and WITHOUT WARRANTY of any kind, to the utmost extent permitted by applicable law, neither express nor implied; without malicious intent or gross negligence. In no event may a licensor, author or contributor be held liable for indirect, direct, other damage, loss, or other issues arising in any way out of dealing in the work, even if advised of the possibility of such damage or existence of a defect, except proven that it results out of said person's immediate fault when using the work as intended. PK!HW"TT(hypothesis_jsonrpc-2.0.0.dist-info/WHEEL A н#J."jm)Afb~ ڡ5 G7hiޅF4+-3ڦ/̖?XPK!HϾf +hypothesis_jsonrpc-2.0.0.dist-info/METADATAV]o6}ׯ V`KY.@ 6 t{HiD$G(w.%%x \);&%䔭kJzhgd5ɼ*){2rٰ`RjI'2}{WK2hªγT+=`*{wտyVMF&y+I^7gg'OaeɽW %!p!dil%u`CtNXʮuy)f:H-`PR:eHsW;֙;)~C7]ͷ~<Rz^sRlc_ǏGGt0k$Of]h_(X3nwiXYa?F`r{@dmVm)zuG~6 U.@Z+E J Ҭ1q!3 $>}-q;nwxŭR+PFTGVC?dk?$zJ0ʞ~&ħѣOx,8<{ǿrN'Bi7dR8*D&ϟ?;e.r}eKA[6_KW(Ǧ; x!0Bc6, ة=o, ̖ٔ|*zC6J>IR9Bxyȴ{k0%q,&6- 8wTb+hVl,oXUc?d]#L6uLզ*"2ZHi0٭0(VCGZeDGRk :eHeP<ֈN|