Download tests/test_taxonomy.py from Imene-ee/Drape: direct link, hf CLI and curl.
- Browser
- Download file 1.72 kB
-
https://huggingface.co/spaces/Imene-ee/Drape/resolve/main/tests/test_taxonomy.py
- Command line
-
hf download hf://spaces/Imene-ee/Drape/tests/test_taxonomy.py
-
curl -L -o test_taxonomy.py https://huggingface.co/spaces/Imene-ee/Drape/resolve/main/tests/test_taxonomy.py
1.72 kB
| import pytest | |
| from drape.taxonomy import GARMENT_KINDS, GROUPS, complete_look_targets, group_from_text | |
| def test_group_from_text(texts, expected): | |
| assert group_from_text(*texts) == expected | |
| def test_category_text_beats_title(): | |
| assert group_from_text("Skirts", "goes great with a crop top") == "bottom" | |
| def test_word_boundaries(): | |
| # "ring" must not match "earring" as a ring, "cap" must not match "cape" etc. | |
| assert group_from_text("String bikini") is None | |
| assert group_from_text("Baggy sweater") == "top" | |
| def test_every_garment_maps_to_known_groups(): | |
| for kind in GARMENT_KINDS: | |
| assert kind.search_groups and set(kind.search_groups) <= set(GROUPS) | |
| def test_complete_look_targets(): | |
| assert complete_look_targets(["top", "bottom"]) == ["shoes", "bag", "outerwear", "accessory"] | |
| assert complete_look_targets(["dress"])[:2] == ["shoes", "bag"] | |
| assert "top" not in complete_look_targets(["dress"]) | |
| assert complete_look_targets(["shoes"])[:2] == ["top", "bottom"] | |
| assert "top" not in complete_look_targets(["outerwear"]) | |
| assert len(complete_look_targets([], max_groups=3)) == 3 | |