No project description provided
Project description
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)
Project details
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
pycodecage-0.1.0.tar.gz
(3.4 kB
view details)
Built Distribution
File details
Details for the file pycodecage-0.1.0.tar.gz
.
File metadata
- Download URL: pycodecage-0.1.0.tar.gz
- Upload date:
- Size: 3.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.11.3 Darwin/22.4.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9ccc53445267eeec735a88dc0d3ea96f065bbe01f49ac06bd66769f023653200 |
|
MD5 | aa11c794c4a7c8d45a072a49d6308758 |
|
BLAKE2b-256 | 055487cf90f782acca6e6f563d9aad313297a577e8ebdae807a159612e7bf28b |
File details
Details for the file pycodecage-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: pycodecage-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.11.3 Darwin/22.4.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f32bbee00cec2b5ef513efc31d1a9217b3bab33735252119ea9fc8076bc36506 |
|
MD5 | 542e937900abe2b32fc1a8cbd1809d3a |
|
BLAKE2b-256 | 56027f648c96aa13d97ac05f634b83fb157d2fe27a6981fe55a896787d655fcc |