No project description provided
Project description
cg_feedback_helpers
This package provides functionality to provide feedback messages. It
mainly provides the class Asserter
. The Asserter
has a number of
methods that are documented on the official
docs, which allow
to run assertions. Each assertion can provide either positive or negative
feedback. A few helpers are also provided to aid with input and output
coupled when running assertions. At the end of a run, call
Asserter::emit_success
to guarantee the user receives some feedback
if everything was correct.
The package outputs feedback in the following format:
{
"tag": "feedback",
"contents": [
{
"value": <your feedback message>,
"sentiment": <"positive" | "negative">
},
]
}
Usage:
The following example shows how the asserter can be used to check that
the function greet_user
responds with the correct output to a user
input.
from cg_feedback_helpers import asserter, helpers
def greet_user():
name = input()
print(f"Hi {name}")
with helpers.capture_output() as buffer, helpers.as_stdin("John"):
greet_user()
output = helpers.get_lines_from_buffer(buffer)
asserter.has_length(output, 1)
asserter.equals(output[0], "John")
asserter.emit_success()
The output of which will be:
{"tag":"feedback","contents":[{"value":"Got expected length 1","sentiment":"positive"}]}
{"tag":"feedback","contents":[{"value":"Got expected value Hi John","sentiment":"positive"}]}
{"tag":"feedback","contents":[{"value":"Everything was correct! Good job!","sentiment":"positive"}]}
Module contains:
Asserter
class, of which the default messages produced can be configured, as well as its failure behavior (either using exceptions orsys.exit
);helpers
to make it easier to work with input/output tests.
Limitation:
The module currently does not support markdown feedback, nor the
neutral
sentiment.
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
Built Distribution
Hashes for cg_feedback_helpers-1!1.0.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 32acca9684738e7c940fa72f3fad73daec324021aa7dac13b8a581680dea8d0c |
|
MD5 | 16bdc17f8dcc08f23c0372fca1fa3454 |
|
BLAKE2b-256 | 5e0b6249a06653b10ec2b4f05e6e471cca2a990555d5eb01293ecfafd80df020 |
Hashes for cg_feedback_helpers-1!1.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3e954ef723be83b6d683836f1e46175dde511d347d5a7500ca344264407fc53d |
|
MD5 | cd2142b7284901fcf058ae205246821f |
|
BLAKE2b-256 | a4c9defe495da06c7b79e460f02fd09bbe5260138894e35738bed2db18abcf2a |