astcheck 0.2.2
pip install astcheck==0.2.2
Newer version available (0.4.0)
Released:
Check Python ASTs against templates
Navigation
Unverified details
These details have not been verified by PyPIProject links
Meta
- License: MIT License (UNKNOWN)
- Author: Thomas Kluyver
Classifiers
- Intended Audience
- License
- Programming Language
- Topic
Project description
astcheck compares Python Abstract Syntax Trees against a template. This is useful for testing software that automatically generates or modifies Python code.
Installation:
pip install astcheck
Example use:
import ast, astcheck
template = ast.Module(body=[
ast.FunctionDef(name='double', args=ast.arguments(args=[astcheck.mkarg('a')])),
ast.Assign(value=ast.Call(func=ast.Name(id='double')))
])
sample = """
def double(a):
do_things()
return a*2
b = double(a)
"""
astcheck.assert_ast_like(ast.parse(sample), template)
Only the parts specified in the template are checked. In this example, the code inside the function, and the assignment target (b) could be anything.
For more details, see the documentation.
Project details
Unverified details
These details have not been verified by PyPIProject links
Meta
- License: MIT License (UNKNOWN)
- Author: Thomas Kluyver
Classifiers
- Intended Audience
- License
- Programming Language
- Topic
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file astcheck-0.2.2.tar.gz
.
File metadata
- Download URL: astcheck-0.2.2.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b7b4c68531a11a1e8aa885d5f19f4534de87312b6ea7dc5a49866338dc1efca0 |
|
MD5 | 538eb01252c308f795e00c50d6b08684 |
|
BLAKE2b-256 | 68b3e65a55d632f3e4290c72db5c79e8ee670dcee25833bc4fe5f2c877c48124 |