Search RU
Tasks / pytest / Properties instead of examples
Statement medium

Properties instead of examples

`parse_tags(raw)` parses a tag string from a query parameter into a list.

Examples:

- `parse_tags("api, Login, API")` → `["api", "login"]`;
- `parse_tags(" , api ,, ")` → `["api"]`;
- `parse_tags("")` → `[]`.

Tags are comma-separated. Every tag is trimmed and lowercased. Empty pieces are
dropped and duplicates collapse. Order follows first appearance.

Write **properties**, not just examples. There is no hypothesis in the
environment, so use `random.Random(seed)` with a fixed seed: at least 100 data
sets so the run stays reproducible.

Check at least:

- every tag is non-empty and lowercase;
- there are no duplicates, even when the casing differs;
- no meaningful piece of the input is lost;
- first-appearance order is preserved;
- re-parsing the result changes nothing.

Plus separate examples for empty input and a string of only commas. A property
without a counterexample easily lets a sort or a lost order through — boundary
examples are needed.

pytestproperty-basedinvariantsrandom
test_solution.py Python 3.14
AI mentor

The AI mentor is available after you log in: it sees your attempt history and does not spend resources on anonymous requests.

Log in and ask
Hints 1 of 3 unlocked · attempts: 0
Hint 1

Which statement about the result holds for **any** input, not just for your five
examples? Start with "all tags are lowercase and unique".

Hint 2 — unlocks after 1 attempt
Hint 3 — unlocks after 3 attempts