Skip to main content
https://travis-ci.org/benemery/pyguard.svg?branch=master https://coveralls.io/repos/benemery/pyguard/badge.svg?branch=master

PyGuard

A python auto test runner inspired by the guard project.

A simple example that runs all the tests when a file is modified would look something like this:

from filewatch import file_updated_subject, Watcher

from pyguard import guardian, GuardianObserver, RegexRule, RuleManager

manager = RuleManager(cmd='py.test pyguard')
manager.register_rules(
        RegexRule(regex=r'.*/pyguard/.*'),
    )

guardian.register_manager(manager)

# Set up our file observer
file_updated_subject.register_observer(GuardianObserver())

# Get our watcher going
watcher = Watcher()
watcher.run()

Any RuleManager that you create will execute the given command whenever a registered rule matches a supplied file path.

To make things a little more granular, we can register a different set of rules. i.e.

...

manager = RuleManager(cmd='py.test pyguard/tests/test_{test_name}.py')
manager.register_rules(
        RegexRule(regex=r'.*/rules.py', cmd_augmentation={'test_name' : 'rules'}),
        RegexRule(regex=r'.*/core.py', cmd_augmentation={'test_name' : 'guardian'}),
    )

guardian.register_manager(manager)

...

To enforce a particular naming convention we can take things even further using named groups within the regex itself. If we have say a views.py and we know that the tests for said views exist in test_views.py, then we can simple use:

...

manager = RuleManager(cmd='py.test pyguard/tests/test_{test_name}.py')
manager.register_rules(
        RegexRule(regex=r'.*/(?P<test_name>views).py'),
    )

guardian.register_manager(manager)

...

Metadata

Release files for pyguard 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyguard 0.0.4
File Size Uploaded Provenance Actions
pyguard-0.0.4.tar.gz 2.7 kB Without provenance Details for pyguard-0.0.4.tar.gz

Release files / pyguard-0.0.4.tar.gz

Download URL pyguard-0.0.4.tar.gz
Size 2.7 kB
Tags Source
SHA-256 checksum
How to use checksums
79af61547dae5ee8338f2a961349c9fa54bd8be5a4597195da72b344253e680f
BLAKE2b-256 checksum
How to use checksums
f1b5b130b4447deeb35fe0b53f36fffe4450a2b54ef8f96a36f72a461824155c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for pyguard 0.0.4

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.4 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page