Samarche
API checker inspired by this post
Quickstart
Say you’re developping a module with a public API, for people working with it, this API is supposed to stay the same until the next major release. What would happen if a commit makes a change it shouldn’t have ?
The solution is testing :
# A class which is part of your API
class Foo:
bar = True
def __init__(self, stuff=False):
self.stuff
def thing(self):
return "doh"
# Your tests to make sure the class stays consistent
self.assertTrue(hasattr(Foo, 'bar'))
self.assertTrue(hasattr(Foo, 'thing'))
self.assertTrue(hasattr(Foo(), 'stuff'))
Unfortunatly those tests are basically writting all your API a second time, there must be a better (and less boring) way !
Samarche allow you to take a snapshop of your API (called a signature) and then be able to test your evolving codebase against it.
Samarche register only public members (i.e. everything starting by _ is skipped) You can create signatures from a module, module.package and even module.package:package_attribute
Example
First build and save the signature of your API:
# Do this at each major release
import samarche
signature = samarche.build_signature("my_api")
with open('my_api.signature', 'wb') as fd:
samarche.dump(signature, f)
Then put somewhere in your tests
with open('my_api.signature', 'rb') as fd:
original_signature = samarche.load(fd)
try:
samarche.check_signature('my_api', original_signature)
except samarche.ValidationError as e:
print("API has changed : {}".format(e))
Metadata
Release files for samarche 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| samarche-0.0.1.tar.gz | 3.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| samarche-0.0.1-py3.4.egg | Legacy Egg format | - | - | Details |
Total release size: 5.0 kB
Release files / samarche-0.0.1.tar.gz
| Download URL | samarche-0.0.1.tar.gz |
|---|---|
| Size | 3.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0e8c46c6ded169b2d33f295ac4f4e5a99a7d8edb6a42babfcebd684eaf46b3bd
|
|
BLAKE2b-256 checksum How to use checksums |
1542a3166ff99a90f0fac2bcccc231080e7bd07932530e6088710c91ad473f72
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / samarche-0.0.1-py3.4.egg
| Download URL | samarche-0.0.1-py3.4.egg |
|---|---|
| Size | 1.1 kB |
| Tags | Egg |
|
SHA-256 checksum How to use checksums |
030b9c323b66635bece1411667a6a76e672a6167f38ad25747c503190a93e1d5
|
|
BLAKE2b-256 checksum How to use checksums |
567f1bd3a6a0149b595d0a7425b73a0320b3ae2bfe7cb8ab5dec71bbcf2b8237
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for samarche 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.