Skip to main content

Context manager that will skip the body on a condition.

Project description

Context manager that will skip the body on a condition.

All code is in conditional_context/__init__.py

from conditional_context import condition

print('start')
value = True
with condition(False):
    value = False
    print('here')  # Will not print
print('end')

assert value
import conditional_context

class MyContext(conditional_context.ConditionalContext):
    def should_skip(self):
        return True

print('start')
value = True
with MyContext():
    value = False
    print('here')  # Will not print
print('end')

assert value

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

conditional_context-1.0.2.tar.gz (4.0 kB view hashes)

Uploaded Source

Built Distribution

conditional_context-1.0.2-py3-none-any.whl (6.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page