Skip to main content

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 or sys.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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cg_feedback_helpers-1!1.0.3.tar.gz (11.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cg_feedback_helpers-1!1.0.3-py3-none-any.whl (14.2 kB view details)

Uploaded Python 3

File details

Details for the file cg_feedback_helpers-1!1.0.3.tar.gz.

File metadata

  • Download URL: cg_feedback_helpers-1!1.0.3.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for cg_feedback_helpers-1!1.0.3.tar.gz
Algorithm Hash digest
SHA256 9598e5ea838de60e1402ea8eed65edc83c4364bc71d95f3da2bacadf73e5c5f5
MD5 7427002d6173eb30a63740e7da6d32eb
BLAKE2b-256 412dfb2c8702260cdc14141b9f5a2ac61a70509753551b7cf1ca711a53e4514f

See more details on using hashes here.

Provenance

The following attestation bundles were made for cg_feedback_helpers-1!1.0.3.tar.gz:

Publisher: production_build.yml on CodeGra-de/CodeGra.de

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cg_feedback_helpers-1!1.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for cg_feedback_helpers-1!1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f881dbc5628c98bf3bc3814153ce81ed215ef57d90e252684ec089e06f74d14f
MD5 9cce2f98053c90fe5a8e49894614ffa8
BLAKE2b-256 19d931d7dc48d17336780eecf5aeba42b56bb96006601d49df83e8906c0838d4

See more details on using hashes here.

Provenance

The following attestation bundles were made for cg_feedback_helpers-1!1.0.3-py3-none-any.whl:

Publisher: production_build.yml on CodeGra-de/CodeGra.de

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page