published: python3 count-tags.py tags.txt run: python3 count-tags.py in/tags-ok.txt tags: 6, with a space: 2, commas: 5 total 46 of 500 characters OK, within the limit, 454 to spare exit=0 edge: test file: 6 tags, one with a space and one with two (within 500) published: python3 count-tags.py tags.txt run: python3 count-tags.py in/tags-over.txt tags: 31, with a space: 31, commas: 30 total 559 of 500 characters OVER by 59 characters exit=1 edge: a 31-tag list over the limit: exit 1 published: python3 count-tags.py tags.txt run: python3 count-tags.py in/missing.txt error: cannot read in/missing.txt ([Errno 2] No such file or directory: 'in/missing.txt') exit=2 edge: a file that does not exist: exit 2 with a message published: python3 count-tags.py tags.txt run: printf "" > in/empty.txt; python3 count-tags.py in/empty.txt error: no tags found in in/empty.txt exit=2 edge: an empty file: exit 2, no tags published: python3 count-tags.py tags.txt run: printf " , ,\n \n" > in/blank.txt; python3 count-tags.py in/blank.txt error: no tags found in in/blank.txt exit=2 edge: only commas and spaces: exit 2, no tags published: python3 count-tags.py tags.txt run: printf "Foo-Baz,Foo Baz\r\n" > in/crlf.txt; python3 count-tags.py in/crlf.txt tags: 2, with a space: 1, commas: 1 total 17 of 500 characters OK, within the limit, 483 to spare exit=0 edge: Windows line break: 17 (7 + 9 + 1 comma) published: python3 count-tags.py tags.txt run: printf "\xef\xbb\xbfFoo-Baz\n" > in/bom.txt; python3 count-tags.py in/bom.txt tags: 1, with a space: 0, commas: 0 total 7 of 500 characters OK, within the limit, 493 to spare exit=0 edge: a file saved with a UTF-8 BOM: 7, the BOM is not counted published: python3 count-tags.py tags.txt run: printf "भारत यात्रा, दिल्ली, खाना बनाना\n" > in/hindi.txt; python3 count-tags.py in/hindi.txt tags: 3, with a space: 2, commas: 2 total 33 of 500 characters OK, within the limit, 467 to spare exit=0 edge: Hindi tags with spaces: 33 code points as in the tool published: python3 count-tags.py tags.txt run: printf "cats\nkitten\nplay\nfunny\n" > in/lines.txt; python3 count-tags.py in/lines.txt tags: 4, with a space: 0, commas: 3 total 22 of 500 characters OK, within the limit, 478 to spare exit=0 edge: one tag per line, no commas: read as 4 tags (the tool needs commas) published: python3 count-tags.py tags.txt run: python3 count-tags.py in error: cannot read in ([Errno 21] Is a directory: 'in') exit=2 edge: a folder instead of a file: exit 2 with a message published: python3 count-tags.py tags.txt run: printf "\xff\xfe" > in/bad.txt; python3 count-tags.py in/bad.txt error: cannot read in/bad.txt ('utf-8' codec can't decode byte 0xff in position 0: invalid start byte) exit=2 edge: bytes that are not UTF-8 (a UTF-16 file): exit 2 with a message published: python3 count-tags.py tags.txt run: python3 count-tags.py usage: python3 count-tags.py [--fit] tags.txt exit=2 edge: no file given: usage line, exit 2 published: python3 count-tags.py tags.txt run: python3 -c "print(\",\".join([\"abcd\"]*100))" > in/b499.txt; python3 count-tags.py in/b499.txt tags: 100, with a space: 0, commas: 99 total 499 of 500 characters OK, within the limit, 1 to spare exit=0 edge: 100 tags of 4 letters: 499, boundary under published: python3 count-tags.py tags.txt run: python3 -c "print(\",\".join([\"abcd\"]*101))" > in/b504.txt; python3 count-tags.py in/b504.txt tags: 101, with a space: 0, commas: 100 total 504 of 500 characters OVER by 4 characters exit=1 edge: 101 tags of 4 letters: 504, boundary over published: python3 count-tags.py tags.txt run: printf "Foo-Baz,Foo Baz,cat video\\n" > in/fig.txt; python3 count-tags.py in/fig.txt tags: 3, with a space: 2, commas: 2 total 29 of 500 characters OK, within the limit, 471 to spare exit=0 edge: the figure list: 7 + 9 + 11 + 2 commas = 29 published: python3 count-tags.py --fit tags.txt run: python3 count-tags.py --fit in/tags-over.txt tags: 31, with a space: 31, commas: 30 total 559 of 500 characters OVER by 59 characters kept 27 of 31 tags, 491 characters: cat video alpha, cat video bravo, cat video charlie, cat video delta, cat video echo, cat video foxtrot, cat video golf, cat video hotel, cat video india, cat video juliet, cat video kilo, cat video lima, cat video mike, cat video november, cat video oscar, cat video papa, cat video quebec, cat video romeo, cat video sierra, cat video tango, cat video uniform, cat video victor, cat video whiskey, cat video xray, cat video yankee, cat video zulu, cat video one dropped: cat video two, cat video three, cat video four, cat video five exit=1 edge: over list: keeps 27 of 31 tags in order, exit 1 published: python3 count-tags.py --fit tags.txt run: python3 count-tags.py --fit in/tags-ok.txt tags: 6, with a space: 2, commas: 5 total 46 of 500 characters OK, within the limit, 454 to spare kept 6 of 6 tags, 46 characters: cats, kitten, play, funny, cute pets, home vlog exit=0 edge: list already within 500: nothing dropped, exit 0 published: python3 count-tags.py --fit tags.txt run: python3 count-tags.py --fit in/empty.txt error: no tags found in in/empty.txt exit=2 edge: an empty file with --fit: exit 2 published: python3 count-tags.py --fit tags.txt run: python3 -c "print(\"x\"*600 + \",ok\")" > in/huge1.txt; python3 count-tags.py --fit in/huge1.txt tags: 2, with a space: 0, commas: 1 total 603 of 500 characters OVER by 103 characters kept 0 of 2 tags, 0 characters: (no tag fits) dropped: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx, ok exit=1 edge: first tag alone is 600 characters: kept 0 tags, exit 1; the later tag ok (2 characters) is dropped too, --fit stops at the first tag that does not fit