Saravanan666/pypi-org huggingface dataset:
Package: hypothesis-graphql
hypothesis-graphqlGenerate queries matching your GraphQL schema, and use them to verify your backend implementationIt is a Python library that provides a set ofHypothesisstrategies that
let you write tests parametrized by a source of examples.
Generated queries have arbitrary depth and may contain any subset of GraphQL types defined in the input schema.
They expose edge cases in your code that are unlikely to be found otherwise.Schemathesisprovides a higher-level interface around this library and finds server crashes automatically.Usagehypothesis-graphqlprovides thefrom_schemafunction, which takes a GraphQL schema and returns a Hypothesis strategy for
GraphQL queries matching the schema:fromhypothesisimportgivenfromhypothesis_graphqlimportfrom_schemaimportrequests# Strings and `graphql.GraphQLSchema` are supportedSCHEMA="""type Book {title: Stringauthor: Author}type Author {name: Stringbooks: [Book]}type Query {getBooks: [Book]getAuthors: [Author]}type Mutation {addBook(title: String!, author: String!): Book!addAuthor(name: String!): Author!}"""@given(from_schema(SCHEMA))deftest_graphql(query):# Will generate samples like these:## {#   getBooks {#     title#   }# }## mutation {#   addBook(title: "H4Z\u7869", author: "\u00d2"){#     title#   }# }response=requests.post("http://127.0.0.1/graphql",json={"query":query})assertresponse.status_code==200assertresponse.json().get("errors")isNoneIt is also possible to generate queries or mutations separately withhypothesis_graphql.queriesandhypothesis_graphql.mutations.CustomizationTo restrict the set of fields in generated operations use thefieldsargument:@given(from_schema(SCHEMA,fields=["getAuthors"]))deftest_graphql(query):# Only `getAuthors` will be generated...It is also possible to generate custom scalars. For example,Date:fromhypothesisimportstrategiesasst,givenfromhypothesis_graphqlimportfrom_schema,nodesSCHEMA="""scalar Datetype Query {getByDate(created: Date!): Int}"""@given(from_schema(SCHEMA,custom_scalars={# Standard scalars work out of the box, for custom ones you need# to pass custom strategies that generate proper AST nodes"Date":st.dates().map(nodes.String)},))deftest_graphql(query):# Example:##  { getByDate(created: "2000-01-01") }#...Thehypothesis_graphql.nodesmodule includes a few helpers to generate various node types:String->graphql.StringValueNodeFloat->graphql.FloatValueNodeInt->graphql.IntValueNodeObject->graphql.ObjectValueNodeList->graphql.ListValueNodeBoolean->graphql.BooleanValueNodeEnum->graphql.EnumValueNodeNull->graphql.NullValueNode(a constant, not a function)They exist because classes likegraphql.StringValueNodecan't be directly used inmapcalls due to kwarg-only arguments.LicenseThe code in this project is licensed underMIT license.
By contributing tohypothesis-graphql, you agree that your contributions will be licensed under its MIT license.
Package: hypothesis-json
hypothesis-jsonThis Python package provides aHypothesisstrategy to generate Python objects compliant to theJavaScript Object Notation (JSON) Data Interchange Formatto uncover unhandled edge cases in your code.Example>>>frompprintimportpprint>>>fromhypothesis_json.strategiesimportjsons>>>pprint(jsons().example()){'':'34.0','-34.0':{'-27566.0':inf,'3.402823466e+38':['11537'],'9007199254740992.0':17857.0,'Infinity':'4794727320289625.0','true':False},'\x14\U000db833':'-14719'}InstallationThe package is published to thePython Package Index (PyPI)and may be installed using your favorite installer, e.g.:pipinstallhypothesis-jsonRemarksGenerated numbers are guaranteed to be processable asdouble-precision floating-point numbersThe non-standard constants supported byPython's json moduleare also generated by default, but may be omittedStatus & VersioningAlthough this is a very young project, it was developed with a strong focus on quality and should be suitable for use in production environments. Versioning of releases will strictly follow theSemantic Versioning Specification (SemVer).LicensingThis project may be licensed under the terms of theOSIapprovedMirOS License.
Package: hypothesis-jsonrpc
hypothesis-jsonrpcThis Python package provides aHypothesisstrategy to generate Python objects compliant to theJSON-RPC 2.0 Specificationto uncover unhandled edge cases in your code.Example>>>frompprintimportpprint>>>fromhypothesis_jsonrpc.strategiesimportrequests>>>pprint(requests().example()){'id':29028,'jsonrpc':'2.0','method':"\U000db1d5\U0004cabb'\x03",'params':{'-105.0':{},'Infinity':['false',-1677172375.0,-inf],'nan':[19940.0]}}InstallationThe package is published to thePython Package Index (PyPI)and may be installed using your favorite installer, e.g.:pipinstallhypothesis-jsonrpcRemarksSo far, only requests, not responses, can be generatedInvalid requests are generated by mutating valid requests and are guranteed to be JSON compliantGenerated numbers are guaranteed to be processable asdouble-precision floating-point numbersThe non-standard constants supported byPython's json modulemay also be generated, but are disabled by defaultStatus & VersioningAlthough this is a very young project, it was developed with a strong focus on quality and should be suitable for use in production environments. Versioning of releases will strictly follow theSemantic Versioning Specification (SemVer).LicensingThis project may be licensed under the terms of theOSIapprovedMirOS License.
Package: hypothesis-jsonschema
hypothesis-jsonschemaAHypothesisstrategy for generating data
that matches someJSON schema.Here's the PyPI page.APIThe public API consists of just one function:hypothesis_jsonschema.from_schema,
which takes a JSON schema and returns a strategy for allowed JSON objects.fromhypothesisimportgivenfromhypothesis_jsonschemaimportfrom_schema@given(from_schema({"type":"integer","minimum":1,"exclusiveMaximum":10}))deftest_integers(value):assertisinstance(value,int)assert1<=value<10@given(from_schema({"type":"string","format":"card"},# Standard formats work out of the box.  Custom formats are ignored# by default, but you can pass custom strategies for them - e.g.custom_formats={"card":st.sampled_from(EXAMPLE_CARD_NUMBERS)},))deftest_card_numbers(value):assertisinstance(value,str)assertre.match(r"^\d{4}\d{4}\d{4}\d{4}$",value)@given(from_schema({},allow_x00=False,codec="utf-8").map(json.dumps))deftest_card_numbers(payload):assertisinstance(payload,str)assert"\0"notinpayload# use allow_x00=False to exclude null characters# If you want to restrict generated strings characters which are valid in# a specific character encoding, you can do that with the `codec=` argument.payload.encode(codec="utf-8")For more details on property-based testing and how to use or customise
strategies,see the Hypothesis docs.JSONSchema drafts 04, 05, and 07 are fully tested and working.
As of version 0.11, this includes resolving non-recursive references!Supported versionshypothesis-jsonschemarequires Python 3.6 or later.
In general, 0.x versions will require very recent versions of all dependencies
because I don't want to deal with compatibility workarounds.hypothesis-jsonschemamay make backwards-incompatible changes at any time
before version 1.x - that's what semver means! - but I've kept the API surface
small enough that this should be avoidable.  The main source of breaks will be
if or when schema that never really worked turn into explicit errors instead
of generating values that don't quite match.You cansponsor meto get priority
support, roadmap input, and prioritized feature development.Contributing tohypothesis-jsonschemaWe love external contributions - and try to make them both easy and fun.
You canread more details in our contributing guide,
andsee everyone who has contributed on GitHub.
Thanks, everyone!ChangelogPatch notescan be found inCHANGELOG.md.Security contact informationTo report a security vulnerability, please use theTidelift security contact.
Tidelift will coordinate the fix and disclosure.
Package: hypothesis-jsonschema-unfit
An experimental project for the generation of JSON data that does NOT match the given JSON schema.fromhypothesisimportgivenfromhypothesis_jsonschema_unfitimportnot_from_schemaSCHEMA={"items":{"type":"object","required":["key1","key2"],"properties":{"key1":{"type":"string"},"key2":{"type":"integer"}},},"type":"array","minItems":4,}@given(not_from_schema(SCHEMA))deftest(instance):...
Package: hypothesis-networkx
Hypothesis-networkxThis module provides a Hypothesis strategy for generating networkx graphs.
This can be used to efficiently and thoroughly test your code.InstallationThis module can be installed viapip:pip install hypothesis-networkxUser guideThe module exposes a single function:graph_builder. This function is a
hypothesis composite strategy for building graphs. You can use it as follows:fromhypothesis_networkximportgraph_builderfromhypothesisimportstrategiesasstimportnetworkxasnxnode_data=st.fixed_dictionaries({'name':st.text(),'number':st.integers()})edge_data=st.fixed_dictionaries({'weight':st.floats(allow_nan=False,allow_infinity=False)})builder=graph_builder(graph_type=nx.Graph,node_keys=st.integers(),node_data=node_data,edge_data=edge_data,min_nodes=2,max_nodes=10,min_edges=1,max_edges=None,self_loops=False,connected=True)graph=builder.example()print(graph.nodes(data=True))print(graph.edges(data=True))Of course this builder is a valid hypothesis strategy, and using it to just
make examples is not super useful. Instead, you can (and should) use it in
your testing framework:fromhypothesisimportgiven@given(graph=builder)deftest_my_function(graph):assertmy_function(graph)==known_function(graph)The meaning of the arguments given tograph_builderare pretty
self-explanatory, but theymustbe given as keyword arguments.node_data: The strategy from which node attributes will be drawn.edge_data: The strategy from which edge attributes will be drawn.node_keys: Either the strategy from which node keys will be draw, or
None. If None, node keys will be integers from the range (0, number of nodes).min_nodesandmax_nodes: The minimum and maximum number of nodes the
produced graphs will contain.min_edgesandmax_edges: The minimum and maximum number of edges the
produced graphs will contain. Note that less
edges thanmin_edgesmay be added if there
are not enough nodes, and more thanmax_edgesifconnectedis True.graph_type: This function (or class) will be called without arguments to
create an empty initial graph.connected: If True, the generated graph is guaranteed to be a single
connected component.self_loops: If False, there will be no self-loops in the generated graph.
Self-loops are edges between a node and itself.Known limitationsThere are a few (minor) outstanding issues with this module:Graph generation may be slow for large graphs.Themin_edgesargument is not always respected when the produced graph
is too small.Themax_edgesargument is not always respected ifconnectedis True.It currently works for Python 2.7, but this is considered deprecated and
may stop working without notice.See alsoNetworkxHypothesis
Package: hypothesis-rdkit
hypothesis-rdkitA strategy to generate random molecules for the hypothesis testing framework. It uses
a collection of fragments generated from the ChEMBL database to construct plausible
molecular graphs. The fragments were mined using theBRICS method.Installationpipinstall-Uhypothesis-rdkitUsageThe modulehypothesis-rdkitprovides a strategy for generating RDKit
molecules. During the installation of the package, this strategy is linked to therdkit.Chem.Moltype:fromhypothesisimportgivenfromrdkit.ChemimportMol@given(...)deftest_molecule_method(mol:Mol):# mol is a randomly generated moleculeassertmol.GetNumAtoms()>0You can use themolsstrategy directly for further customization:fromhypothesisimportgivenfromhypothesis_rdkitimportmolsfromrdkit.ChemimportGetMolFrags,Molfromrdkit.Chem.rdMolDescriptorsimportCalcNumRotatableBonds@given(mols(n_connected_components=2,max_rotatable_bonds=5,n_conformers=10))deftest_molecule_mixtures(mol:Mol):frags=GetMolFrags(mol,asMols=True)assertlen(frags)==2forfraginfrags:assertCalcNumRotatableBonds(frag)<=5assertmol.GetNumConformers()<=10There are also strategies to generate molecules in SMILES, mol block or InChI
representation accepting the same parameters asmols:fromhypothesisimportgivenfromhypothesis_rdkitimportsmiles,mol_blocks,inchisfromrdkit.ChemimportMolFromSmiles,MolFromMolBlock,MolFromInchi@given(smiles())deftest_smiles(smiles:str):mol=MolFromSmiles(smiles)assertmolisnotNoneandmol.GetNumAtoms()>0@given(mol_blocks())deftest_mol_block(mol_block:str):mol=MolFromMolBlock(mol_block)assertmolisnotNoneandmol.GetNumAtoms()>0@given(inchis())deftest_inchi(inchi:str):mol=MolFromInchi(inchi)assertmolisnotNoneandmol.GetNumAtoms()>0
Package: hypothesis-regex
Hypothesisextension
to allow generating strings based on regex. Useful in case you have some schema
(e.g. JSON Schema) which already has regular expressions validating data.Examplefromhypothesis_regeximportregeximportrequestsimportjsonEMAIL_REGEX=r"^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]{2,}\.[a-zA-Z0-9-.]{2,}$"@given(regex(EMAIL_REGEX))deftest_registering_user(email):response=requests.post('/signup',json.dumps({'email':email}))assertresponse.status_code==201FeaturesRegex strategy returns strings that always match given regex (this check is
enforced by a filter) and it tries to do that in an effective way so that less
generated examples are filtered out. However, some regex constructs may decrease
strategy efficiency and should be used with caution:“^” and “$” in the middle of a string - do not do anything.“\b” and “\B” (word boundary and not a word boundary) - do not do anything and
instead just rely on top-level regex match filter to filter out non-matching
examples.positive lookaheads and lookbehinds just generate data they should match (as if
it was part of preceeding/following parts).negative lookaheads and lookbehinds do not do anything so it relies on
preceeding/following parts to generate correct strings (otherwise the example will
be filtered out).“(?(id)yes-pattern|no-pattern)” does not actually check if group with given id
was actually used and instead just generates either yes- or no-pattern.Regex strategy tries to go all crazy about generated data (e.g. “$” at the end of a
string either does not generate anything or generate a newline). The idea is not to
generate a nicely looking strings but instead any craze unexpected combination that
will still match your given regex so you can prepare for those and handle them in
most apropriate way.You can use regex flags to get more control on strategy:re.IGNORECASE - literals or literal ranges generate both lowercase and uppercase
letters. E.g.r’a’will generate both“a”and“A”, or‘[a-z]’will generate
both lowercase and uppercase english characters.re.DOTALL - “.” char will be able to generate newlinesre.UNICODE - character categories
(”\w”, “\d” or “\s” and their negations) will generate unicode characters.
This is default for Python 3, see re.ASCII to reverse it.There are two ways to pass regex flags:By passing compiled regex with that flags:regex(re.compile(‘abc’, re.IGNORECASE))By using inline flags syntax:regex(‘(?i)abc’)Installation$ pip install hypothesis-regexRequirementsPython >= 2.7 and <= 3.6hypothesis>= 3.8Project LinksPyPI:https://pypi.python.org/pypi/hypothesis-regexIssues:https://github.com/maximkulkin/hypothesis-regex/issuesLicenseMIT licensed. See the bundledLICENSEfile for more details.
Package: hypothesis-requests
hypothesis-requestsHomepageBy Alex Brandtalunduil@gmail.comDescriptionYou can use hypothesis-requests to generate [request] objects for hypothesis
based tests.Terms of useSee the [LICENCE] file for details.PrerequisitesHypothesis property based testsHow to use this templateAdd hypothesis-requests to your project dependencies.Utilise hypothesis_requests.strategies to generate Requests, Responses, etc.DocumentationLICENSE: The license governing use of template.pyGetting HelpGitHub Issues: Support requests, bug reports, and feature requestsHow to HelpSubmitissuesfor problems or questionsSubmitpull requestsfor proposed changes
Package: hypothesis-ros
hypothesis-rosHypothesis strategies for ROS node level property based testing.Installation❯ pip install git+https://github.com/ros-testing/hypothesis-rosUsage❯ pip install ipython
❯ ipython
In [1]: from hypothesis_ros.message_fields import int16
In [2]: int16().example()
Out[2]:-32183
In [3]: int16(min_value=5, max_value=5).example()
Out[3]: 5Examples❯ pip install jupyter
❯ cd docs/source/notebooks/
❯ jupyter labDocumentationSphinx documentation (user's guide, API reference)Build the documentation.❯ tox -e docsOpen the documentation.❯ xdg-open ./docs/build/index.htmlInteractive documentation (API reference)❯ ipython
In [1]: from hypothesis_ros import message_fields
In [2]: message_fields?
(module documentation)
In [3]: message_fields.<TAB-replacement>?
(documentation of strategies, etc.)
Package: hypothesis-trio
Welcome tohypothesis-trio!Hypothesis supports Trio out of the box for non-stateful tests.
This project aims at supporting the stateful mode ;-)License: Your choice of MIT or Apache License 2.0UsageReplacehypothesis.stateful.RuleBasedStateMachinebyhypothesis_trio.stateful.TrioRuleBasedStateMachine:fromhypothesis_trio.statefulimportTrioRuleBasedStateMachine,run_state_machine_as_testdeftest_trio_number_modifier(hypothesis_settings):classNumberModifier(TrioRuleBasedStateMachine):folders=Bundle('folders')files=Bundle('files')@initialize(target=folders)asyncdefinit_folders(self):awaittrio.sleep(0)return'/'@rule(target=folders,name=name_strategy)asyncdefcreate_folder(self,parent,name):awaittrio.sleep(0)return'%s/%s'%(parent,name)@rule(target=files,name=name_strategy)asyncdefcreate_file(self,parent,name):awaittrio.sleep(0)return'%s/%s'%(parent,name)asyncdefteardown(self):awaittrio.sleep(0)run_state_machine_as_test(NumberModifier,settings=hypothesis_settings)Support for Trio-Asynciotrio-asyncioallows to mix asyncio and trio code altogether.
To support it in your test, you should usehypothesis_trio.stateful.TrioAsyncioRuleBasedStateMachine:classCheckAsyncioLoop(TrioAsyncioRuleBasedStateMachine):@initialize()asyncdefinitialize(self):assertself.get_asyncio_loop()==asyncio.get_event_loop()awaittrio_asyncio.aio_as_trio(lambda:asyncio.sleep(0))
Package: hypothesize
HypothesizeA Python package for hypothesis testing using robust statisticsBasic ExampleA robust measure of association with winsorized correlationfromhypothesize.measuring_associationsimportwincorfromhypothesize.utilitiesimportcreate_example_data# creating an example DataFrame with columns "cell_1" and "cell_2"df=create_example_data(2)results=wincor(df.cell_1,df.cell_2)# returning the correlation, number of observations, p-value, and winsorized covarianceprint(results){'cor':0.11,'nval':50,'sig':0.44,'wcov':0.01}Documentation:book: Please visit theHypothesize documentation site.
Note that each statistical test in the can be launched
directly inDeepnote'shosted notebook environment—complete with sample data
(as shown in the example above 👆).Citing HypothesizeIf you use Hypothesize in academic work, please use the following citation:Campopiano, A., & Wilcox, R. R. (2020). Hypothesize: Robust Statistics for Python.
Journal of Open Source Software, 5(50), 2241,https://doi.org/10.21105/joss.02241BibTex:@article{Campopiano2020,doi={10.21105/joss.02241},url={https://doi.org/10.21105/joss.02241},year={2020},publisher={The Open Journal},volume={5},number={50},pages={2241},author={Allan Campopiano and Rand R. Wilcox},title={Hypothesize: Robust Statistics for Python},journal={Journal of Open Source Software}}
Package: hypothesmith
hypothesmithHypothesis strategies for generating Python programs, something like CSmith.This is definitely pre-alpha, but if you want to play with it feel free!
You can even keep the shiny pieces when - not if - it breaks.Get it today withpip install hypothesmith,
or by cloningthe GitHub repo.You can run the tests, such as they are, withtoxon Python 3.6 or later.
Usetox -vato see what environments are available.UsageThis package provides two Hypothesis strategies for generating Python source code.The generated code will always be syntatically valid, and is useful for testing
parsers, linters, auto-formatters, and other tools that operate on source code.DO NOT EXECUTE CODE GENERATED BY THESE STRATEGIES.It could do literally anything that running Python code is able to do,
including changing, deleting, or uploading important data.  Arbitrary
code can be useful, but "arbitrary code execution" can be very, very bad.hypothesmith.from_grammar(start="file_input", *, auto_target=True)Generates syntactically-valid Python source code based on the grammar.Valid values forstartare"single_input","file_input", or"eval_input"; respectively a single interactive statement, a module or
sequence of commands read from a file, and input for the eval() function.Ifauto_targetisTrue, this strategy useshypothesis.target()internally to drive towards larger and more complex examples.  We recommend
leaving this enabled, as the grammar is quite complex and only simple examples
tend to be generated otherwise.hypothesmith.from_node(node=libcst.Module, *, auto_target=True)Generates syntactically-valid Python source code based on the node types
defined by theLibCSTproject.You can pass any subtype oflibcst.CSTNode.  Alternatively, you can use
Hypothesis' built-infrom_type(node_type).map(lambda n: libcst.Module([n]).code,
after Hypothesmith has registered the required strategies.  However, this does
not include automatic targeting and limitations of LibCST may lead to invalid
code being generated.Notable bugs found with HypothesmithBPO-40661, a segfault in the new parser,
was given maximum priority and blocked the planned release of CPython 3.9 beta1.BPO-38953tokenize->untokenizeroundtrip bugs.BPO-42218mishandled error case in new PEG parser.lib2to3errors on \r in commentBlack fails on files ending in a backslashAt least three round-trip bugs in LibCST(search commits for "hypothesis")Invalid code generated by LibCSTChangelogPatch notescan be found inCHANGELOG.md.