Skip to main content

Testcase Maker

Downloads

pypi

docs

python

license

Competitive programming testcases made easy!

About

**NOTE: The library is a work-in-progress, there may be breaking changes.

When creating competitive programming challenges, we will also need to create testcases. These testcases may be very

large with millions of numbers, which makes it near impossible to do manually. This library will allow you to automate

this process. It provides an intuitive API to build, generate and validate testcases.

Testcase Maker aims to be:

  • Very modular and expandable API structure

  • Fast and efficient

  • Extensive documentation and examples

Testcase Maker is feature-packed with:

  • Highly customisable values to suit large range of challenges

  • Separate constraints for subtasks

  • Execute answer scripts in java, cpp or python to get stdout

Installation

This lib is hosted on pypi, thus you can install this lib by typing the following line:


pip install testcase-maker

Basics Usage

You can get started generating testcases with just a few lines of code. Here is a simple example of generating testcases

with N number of random integers, i.

import logging



from testcase_maker.generator import TestcaseGenerator

from testcase_maker.values import ValueGroup, NamedValue, RandomInt, LoopValue, ValueRef



logging.basicConfig(level=logging.INFO)



values = ValueGroup()

# Define the N value.

values.add(NamedValue(name="N", value=RandomInt(min=50, max=1000)))

values.newline()

# Define the N number of integers.

values.add(LoopValue(

    value=NamedValue(name="i", value=RandomInt(min=1, max=1000)),

    amount=ValueRef("N"),

    delimiter=" ",

))



# Generate stdin testcases

generator = TestcaseGenerator(values=values)

generator.generate_stdin()

Some challenges has subtasks with testcases requiring different constraints. Continuing from the previous example, here

is how you can do it with Testcase Maker.

# ...replacing generator code from the simple example...

# Generate stdin testcases

generator = TestcaseGenerator(values=values)



# Reduce the range of both N and i values.

easy = generator.new_subtask(no_of_testcase=2)

easy.override_value(name="N", value=RandomInt(min=2, max=5))

easy.override_value(name="i", value=RandomInt(min=1, max=100))



# Reduce the range of N. Slightly harder but still less than default.

medium = generator.new_subtask(no_of_testcase=2)

medium.override_value(name="N", value=RandomInt(min=6, max=50))



# Using default constraints. This will generate the largest set of testcases.

hard = generator.new_subtask(no_of_testcase=2)



generator = TestcaseGenerator(values=values)

generator.generate_stdin()

Apart from stdin, you can also generate stdout with an answer script.

# ...replacing generator code from the simple example...

# Generate stdin and stdout testcases

generator = TestcaseGenerator(values=values, answer_script="./solutions.py")

generator.generate()
# solution.py

N = int(input())

numbers = [int(x) for x in input().split()]

numbers.sort()

print(" ".join([str(x) for x in numbers]))

Advanced

There are still so many other things you can do with this library. For more advanced and detailed usage guide, please refer to

the official documentation!

License

This project is license with MIT. Read full details at LICENSE file.

Metadata

Release files for testcase-maker 0.3.0.post0

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

Source distribution (sdist)

Source distribution for testcase-maker 0.3.0.post0
File Size Uploaded Provenance Actions
testcase-maker-0.3.0.post0.tar.gz 11.5 kB Without provenance Details for testcase-maker-0.3.0.post0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for testcase-maker 0.3.0.post0
File Interpreter ABI Platform Actions
testcase_maker-0.3.0.post0-py3-none-any.whl Python 3 none any Details for testcase_maker-0.3.0.post0-py3-none-any.whl

Total release size: 27.3 kB

Release files / testcase-maker-0.3.0.post0.tar.gz

Download URL testcase-maker-0.3.0.post0.tar.gz
Size 11.5 kB
Tags Source
SHA-256 checksum
How to use checksums
ee375da8a21ecba1076432b029f3df68378a3da0ba1e888cf8a24d2fb8f2d641
BLAKE2b-256 checksum
How to use checksums
22172ad23934f3557ab1c5f414c042fc079da453af5deba1f049215ee9f64b39
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

Release files / testcase_maker-0.3.0.post0-py3-none-any.whl

Download URL testcase_maker-0.3.0.post0-py3-none-any.whl
Size 15.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
82121562fc0b9fddc68966088f46cdca9f165f186fb1d2c7ab89bc1096aefa97
BLAKE2b-256 checksum
How to use checksums
96db40cb9b577c6a9c079db3310fdb91ac99250a24454cab3f48ca89c8aad1a0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

Security for testcase-maker 0.3.0.post0

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.

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