pycodecage


Namepycodecage JSON
Version 0.1.2 PyPI version JSON
download
home_page
Summary
upload_time2023-08-17 14:27:02
maintainer
docs_urlNone
authoriYasha
requires_python>=3.6,<3.12
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # PyCodeCage

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

## Installation

Use the package manager pip to install PyCodeCage.

```bash
pip install PyCodeCage
```

## Example

```python
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)
```



            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "pycodecage",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6,<3.12",
    "maintainer_email": "",
    "keywords": "",
    "author": "iYasha",
    "author_email": "33287747+iYasha@users.noreply.github.com",
    "download_url": "https://files.pythonhosted.org/packages/2f/0a/6a653e460081d8a4f46baceb37d05e28417465a18d9b60f933f5a5526ba4/pycodecage-0.1.2.tar.gz",
    "platform": null,
    "description": "# PyCodeCage\n\nPyCodeCage is a Python library for running code in a sandboxed environment.\n\n## Installation\n\nUse the package manager pip to install PyCodeCage.\n\n```bash\npip install PyCodeCage\n```\n\n## Example\n\n```python\nfrom pycodecage import TestCase, TrustedEnvironment, run_tests\n\ncode = \"\"\"\na = int(input(\"Enter an integer:\"))\n\nif a % 2 != 0 and a > 20:\n    print(\"Not Weird\")\nelif a % 2 != 0:\n    print(\"Weird\")\nelif a % 2 == 0 and 2 <= a <= 5:\n    print(\"Not Weird\")\nelif a % 2 == 0 and 6 <= a <= 20:\n    print(\"Weird\")\n\"\"\"\n\nenv = TrustedEnvironment(code)\ntests = [\n    TestCase('test1', [1], ['Weird']),\n    TestCase('test2', [3], ['Weird']),\n    TestCase('test3', [2], ['Not Weird']),\n    TestCase('test4', [4], ['Not Weird']),\n    TestCase('test5', [6], ['Weird']),\n    TestCase('test6', [8], ['Weird']),\n    TestCase('test7', [20], ['Weird']),\n    TestCase('test8', [39], ['Not Weird']),\n]\nrun_tests(tests, env)\n```\n\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "",
    "version": "0.1.2",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d790cb4dd63126bfea653d0d19de0d8a4c8fa7b4c259e4ee467d23cf23033786",
                "md5": "aea8911749c641b884913c3359024eb4",
                "sha256": "3ea5499855cb13b89eea4df04dcc8c9a836db850fccc870614bb7d9e78c2ae11"
            },
            "downloads": -1,
            "filename": "pycodecage-0.1.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "aea8911749c641b884913c3359024eb4",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6,<3.12",
            "size": 4895,
            "upload_time": "2023-08-17T14:27:01",
            "upload_time_iso_8601": "2023-08-17T14:27:01.191183Z",
            "url": "https://files.pythonhosted.org/packages/d7/90/cb4dd63126bfea653d0d19de0d8a4c8fa7b4c259e4ee467d23cf23033786/pycodecage-0.1.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2f0a6a653e460081d8a4f46baceb37d05e28417465a18d9b60f933f5a5526ba4",
                "md5": "199385c8ff7f14340d82f416d0360e9c",
                "sha256": "bcafd76d311e6824fe7923101f8af33d746e63fbd315a2996700b6a66258871e"
            },
            "downloads": -1,
            "filename": "pycodecage-0.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "199385c8ff7f14340d82f416d0360e9c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6,<3.12",
            "size": 3448,
            "upload_time": "2023-08-17T14:27:02",
            "upload_time_iso_8601": "2023-08-17T14:27:02.463222Z",
            "url": "https://files.pythonhosted.org/packages/2f/0a/6a653e460081d8a4f46baceb37d05e28417465a18d9b60f933f5a5526ba4/pycodecage-0.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-17 14:27:02",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "pycodecage"
}
        
Elapsed time: 0.15520s