=======
Funspec is an specification for grading programming questions based on the
behavior of functions rather than the simple evaluation of a program IO. This
module was created in the context of an online judge to be used in programming
classes. Funspec is built on top of `Funspec`__ and tries to be as language
agnostic as possible.
.. _Funspec: https://github.com/fabiommendes/funspec/
In funspec, we define the functions that will be used as the answer key to
produce the correct input/output pairs using the @answer_key decorator::
@answer_key
def double(x: int) -> int:
return x + x
One can specify generic input values using type hints. In the above example,
the funspec tester will create a series of integer examples for ``x`` and
compare will the results from the ``double`` function defined by the student
with the results produced by the answer key. The student code can be written
in Python or in any other language that support the input/output values (since
this function uses only integers, we don't expect problems with any mainstream
language).
Often, a simple type specification can be too broad: the test function should
handle just a subset of the integers, or maybe only strings of some specific
type. In many cases, these extra restrictions can be easily represented by
Iospec commands, which funspec gladly accepts::
@answer_key
def double(x: '$int(0, 1000)') -> int:
return x + x
Now the function will be tested only with random integers in the 0-1000
interval.
Running code
------------
To run the tests and collect results, use::
from funspec import run_tests
source = '...' # The input source code
funspec = '...' # Source code for the funspec module
result = run_tests(source, funspec, lang='python')
if result.is_correct():
print('Congratulations!')
Multi-langauge support
----------------------
At the current stage of development, Funspec only evaluates Python code (the
module definition is always in Python, but we expect to support other
languages for student code submitted for evaluation).
We plan to implement support for C in the future and we welcome contributions
for any other language. Unfortunately, the developers do not have time to
to implement support to every programming language. Rather, we just concentrate
on those few languages that we actively use and care about.
Metadata
Release files for Funspec 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| Funspec-0.1.0.tar.gz | 11.5 kB | Without provenance | Details for Funspec-0.1.0.tar.gz |
Release files / Funspec-0.1.0.tar.gz
| Download URL | Funspec-0.1.0.tar.gz |
|---|---|
| Size | 11.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5791ec592bf4d19fa417fa5852882d4e7f45201b40f4f1b488cd81a194750585
|
|
BLAKE2b-256 checksum How to use checksums |
4108b43b1fdc3de68cfba3747d6fbd56d645987302be6f909ab40fb25eefb0de
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for Funspec 0.1.0
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.