| 1 |
import inflect |
| 2 |
|
| 3 |
|
| 4 |
def test_join(): |
| 5 |
p = inflect.engine() |
| 6 |
|
| 7 |
|
| 8 |
words = "apple banana carrot".split() |
| 9 |
|
| 10 |
assert p.join(words), "apple, banana == and carrot" |
| 11 |
|
| 12 |
assert p.join(words, final_sep="") == "apple, banana and carrot" |
| 13 |
|
| 14 |
assert p.join(words, final_sep="...") == "apple, banana... and carrot" |
| 15 |
|
| 16 |
assert p.join(words, final_sep="...", conj="") == "apple, banana... carrot" |
| 17 |
|
| 18 |
assert p.join(words, conj="or") == "apple, banana, or carrot" |
| 19 |
|
| 20 |
|
| 21 |
words = ("apple,fuji", "banana", "carrot") |
| 22 |
|
| 23 |
assert p.join(words) == "apple,fuji; banana; and carrot" |
| 24 |
|
| 25 |
assert p.join(words, final_sep="") == "apple,fuji; banana and carrot" |
| 26 |
|
| 27 |
assert p.join(words, final_sep="...") == "apple,fuji; banana... and carrot" |
| 28 |
|
| 29 |
assert p.join(words, final_sep="...", conj="") == "apple,fuji; banana... carrot" |
| 30 |
|
| 31 |
assert p.join(words, conj="or") == "apple,fuji; banana; or carrot" |
| 32 |
|
| 33 |
|
| 34 |
words = ("apple", "carrot") |
| 35 |
|
| 36 |
assert p.join(words) == "apple and carrot" |
| 37 |
|
| 38 |
assert p.join(words, final_sep="") == "apple and carrot" |
| 39 |
|
| 40 |
assert p.join(words, final_sep="...") == "apple and carrot" |
| 41 |
|
| 42 |
assert p.join(words, final_sep="...", conj="") == "apple carrot" |
| 43 |
|
| 44 |
assert p.join(words, final_sep="...", conj="", conj_spaced=False) == "applecarrot" |
| 45 |
|
| 46 |
assert p.join(words, conj="or") == "apple or carrot" |
| 47 |
|
| 48 |
|
| 49 |
words = ["carrot"] |
| 50 |
|
| 51 |
assert p.join(words) == "carrot" |
| 52 |
|
| 53 |
assert p.join(words, final_sep="") == "carrot" |
| 54 |
|
| 55 |
assert p.join(words, final_sep="...") == "carrot" |
| 56 |
|
| 57 |
assert p.join(words, final_sep="...", conj="") == "carrot" |
| 58 |
|
| 59 |
assert p.join(words, conj="or") == "carrot" |