AI Agent Use Cases

Added today

44All 189

Prompt to Prepare a Shopping Cart from a Recipe Photo

The author reports that Grok Bot receives a recipe photo, organizes the ingredients and quantities, and creates a shopping list by excluding ingredients already available at home.

Grok Bot
Life & Hobbies

1–20 of 189

DevWalkthrough

Drafting Normal, Boundary, and Error Tests from Python Code

The author reports generating and saving a draft pytest file to check normal inputs and exceptional situations for a given Python file.

How it works

  1. The author specifies the target Python file with --file or inserts short code with --code. Before execution, they prepare the example's package and model API settings.
  2. The author requests the model to create tests that separately check normal inputs, boundary values, and error conditions. They instruct that external APIs or file handling should be replaced with mock operations within the tests.
  3. The generated content is saved as test_filename.py or to a specified --output path. The program shows the pytest command to run next, but does not execute the tests itself.

Results

This is an example of generating a pytest test file. The high coverage goal mentioned in the original is a model instruction, not a measured outcome.

Notes

It is necessary to run and review the generated tests to ensure they use correct expected values. The default save code does not prevent overwriting existing output files.

Source

GitHub Original post ↗

Example prompt · LangChain

Set up a tool to draft tests for [Python module]. Refer to the code input and file saving methods of agents/15-unit-test-generator and proceed in a [test work copy]. First, organize the packages to install, API settings, and the test execution command.

Separate normal input, empty input, boundary values, and exception conditions. Replace external API, file, and database operations with mocks. Save as a new file without overwriting existing test files, and base expected values on [confirmed requirements] rather than simply following current function behavior.

After generation, actually run the tests and record passes and failures. Check that relevant tests fail when you intentionally introduce small errors, and only note coverage figures if measured. The deliverables are the test file, execution log, test items by requirement, and unverified paths. The original only covers file generation, so treat execution and error detection verification as additional steps in this implementation.