| 1 |
import inflect |
| 2 |
|
| 3 |
p = inflect.engine() |
| 4 |
|
| 5 |
|
| 6 |
def test_compound_1(): |
| 7 |
assert p.singular_noun("hello-out-there") == "hello-out-there" |
| 8 |
|
| 9 |
|
| 10 |
def test_compound_2(): |
| 11 |
assert p.singular_noun("hello out there") == "hello out there" |
| 12 |
|
| 13 |
|
| 14 |
def test_compound_3(): |
| 15 |
assert p.singular_noun("continue-to-operate") == "continue-to-operate" |
| 16 |
|
| 17 |
|
| 18 |
def test_compound_4(): |
| 19 |
assert p.singular_noun("case of diapers") == "case of diapers" |
| 20 |
|
| 21 |
|
| 22 |
def test_unit_handling_degree(): |
| 23 |
test_cases = { |
| 24 |
"degree celsius": "degrees celsius", |
| 25 |
|
| 26 |
"degree fahrenheit": "degrees fahrenheit", |
| 27 |
"degree rankine": "degrees rankine", |
| 28 |
"degree fahrenheit second": "degree fahrenheit seconds", |
| 29 |
} |
| 30 |
for singular, plural in test_cases.items(): |
| 31 |
assert p.plural(singular) == plural |
| 32 |
|
| 33 |
|
| 34 |
def test_unit_handling_fractional(): |
| 35 |
test_cases = { |
| 36 |
"pound per square inch": "pounds per square inch", |
| 37 |
"metre per second": "metres per second", |
| 38 |
"kilometre per hour": "kilometres per hour", |
| 39 |
"cubic metre per second": "cubic metres per second", |
| 40 |
"dollar a year": "dollars a year", |
| 41 |
|
| 42 |
"foot per square second": "feet per square second", |
| 43 |
"mother-in-law per lifetime": "mothers-in-law per lifetime", |
| 44 |
"pound-force per square inch": "pounds-force per square inch", |
| 45 |
} |
| 46 |
for singular, plural in test_cases.items(): |
| 47 |
assert p.plural(singular) == plural |
| 48 |
|
| 49 |
|
| 50 |
def test_unit_handling_combined(): |
| 51 |
test_cases = { |
| 52 |
|
| 53 |
"watt per square meter degree celsius": "watts per square meter degree celsius", |
| 54 |
"degree celsius per hour": "degrees celsius per hour", |
| 55 |
"degree fahrenheit hour square foot per btuit inch": ( |
| 56 |
"degree fahrenheit hour square feet per btuit inch" |
| 57 |
), |
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
} |
| 62 |
for singular, plural in test_cases.items(): |
| 63 |
assert p.plural(singular) == plural |
| 64 |
|
| 65 |
|
| 66 |
def test_unit_open_compound_nouns(): |
| 67 |
test_cases = { |
| 68 |
"high school": "high schools", |
| 69 |
"master genie": "master genies", |
| 70 |
"MASTER genie": "MASTER genies", |
| 71 |
"Blood brother": "Blood brothers", |
| 72 |
"prima donna": "prima donnas", |
| 73 |
"prima DONNA": "prima DONNAS", |
| 74 |
} |
| 75 |
for singular, plural in test_cases.items(): |
| 76 |
assert p.plural(singular) == plural |
| 77 |
|
| 78 |
|
| 79 |
def test_unit_open_compound_nouns_classical(): |
| 80 |
p.classical(all=True) |
| 81 |
test_cases = { |
| 82 |
"master genie": "master genii", |
| 83 |
"MASTER genie": "MASTER genii", |
| 84 |
"Blood brother": "Blood brethren", |
| 85 |
"prima donna": "prime donne", |
| 86 |
"prima DONNA": "prime DONNE", |
| 87 |
} |
| 88 |
for singular, plural in test_cases.items(): |
| 89 |
assert p.plural(singular) == plural |
| 90 |
p.classical(all=False) |