Mozilla Public License 2.0

项目介绍

Zac-HD/hypothesmith 是一个托管在 GitHub 上的开源项目,主要使用 Python 编写,采用 Mozilla Public License 2.0 许可证,目前获得 120 个 Star、10 次 Fork。

仓库全名
Zac-HD/hypothesmith
开源许可证
Mozilla Public License 2.0
Star 数
120
Fork 数
10
未关闭 Issue
10

README 摘要

hypothesmith Hypothesis 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 with pip install hypothesmith, or by cloning the GitHub repo. You can run the tests, such as they are, with tox on Python 3.6 or later. Use tox -va to see what environments are…

完整内容见 GitHub 原始 README 或本页 。

常见问题

hypothesmith 用什么语言开发?

主要使用 Python 编写,采用 Mozilla Public License 2.0 许可证,目前有 120 个 Star。

hypothesmith 可以免费商用吗?

仓库标注的许可证为 Mozilla Public License 2.0,商用前请先阅读仓库 LICENSE 文件确认授权范围。

如何获取 hypothesmith 的源码?

可以直接克隆仓库:git clone https://github.com/Zac-HD/hypothesmith.git,默认分支为 master;安装与运行步骤见仓库 README。

hypothesmith 最近还在维护吗?

仓库最近一次更新为 2024年2月17日,当前有 10 个未关闭 Issue;Star 数为 120,可作为社区活跃度的参考。

关于

GitHub 原始描述(英文)

Hypothesis strategies for generating Python programs, something like CSmith

描述取自 GitHub 官方 API,保持仓库作者书写的原文。

简要分析

热度分
147
价值分
75
活跃状态
活跃

语言占比

Python

README

hypothesmith

Hypothesis 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 with pip install hypothesmith, or by cloning the GitHub repo.

You can run the tests, such as they are, with tox on Python 3.6 or later. Use tox -va to see what environments are available.

Usage

This 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 for start are "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.

If auto_target is True, this strategy uses hypothesis.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 the LibCST project.

You can pass any subtype of libcst.CSTNode. Alternatively, you can use Hypothesis’ built-in from_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 Hypothesmith

Changelog

Patch notes can be found in CHANGELOG.md.

评论

暂无评论