Skip to main content

PyCodeCage

PyCodeCage is a Python library for running code in a sandboxed environment.

Installation

Use the package manager pip to install PyCodeCage.

pip install PyCodeCage

Example

from pycodecage import TestCase, TrustedEnvironment, run_tests

code = """
a = int(input("Enter an integer:"))

if a % 2 != 0 and a > 20:
    print("Not Weird")
elif a % 2 != 0:
    print("Weird")
elif a % 2 == 0 and 2 <= a <= 5:
    print("Not Weird")
elif a % 2 == 0 and 6 <= a <= 20:
    print("Weird")
"""

env = TrustedEnvironment(code)
tests = [
    TestCase('test1', [1], ['Weird']),
    TestCase('test2', [3], ['Weird']),
    TestCase('test3', [2], ['Not Weird']),
    TestCase('test4', [4], ['Not Weird']),
    TestCase('test5', [6], ['Weird']),
    TestCase('test6', [8], ['Weird']),
    TestCase('test7', [20], ['Weird']),
    TestCase('test8', [39], ['Not Weird']),
]
run_tests(tests, env)

Metadata

Release files for pycodecage 0.1.2

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

Source distribution (sdist)

Source distribution for pycodecage 0.1.2
File Size Uploaded
pycodecage-0.1.2.tar.gz 3.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pycodecage 0.1.2
File Interpreter ABI Platform
pycodecage-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 8.3 kB

Release files / pycodecage-0.1.2.tar.gz

Download URL pycodecage-0.1.2.tar.gz
Size 3.4 kB
Tags Source
SHA-256 checksum
How to use checksums
bcafd76d311e6824fe7923101f8af33d746e63fbd315a2996700b6a66258871e
BLAKE2b-256 checksum
How to use checksums
2f0a6a653e460081d8a4f46baceb37d05e28417465a18d9b60f933f5a5526ba4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.5.1 CPython/3.11.0 Linux/5.15.0-1042-azure

Release files / pycodecage-0.1.2-py3-none-any.whl

Download URL pycodecage-0.1.2-py3-none-any.whl
Size 4.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3ea5499855cb13b89eea4df04dcc8c9a836db850fccc870614bb7d9e78c2ae11
BLAKE2b-256 checksum
How to use checksums
d790cb4dd63126bfea653d0d19de0d8a4c8fa7b4c259e4ee467d23cf23033786
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.5.1 CPython/3.11.0 Linux/5.15.0-1042-azure

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

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