Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"singular_noun(%s) == %s != %s" % (plur, p.singular_noun(plur), sing))
self.assertEqual(p.inflect('singular_noun(%s)' % plur), sing)
p.gender('neuter')
for sing, plur in (
('it', 'they'),
('itself', 'themselves'),
('its', 'theirs'),
('to it', 'to them'),
('to itself', 'to themselves'),
):
self.assertEqual(p.singular_noun(plur), sing,
"singular_noun(%s) == %s != %s" % (plur, p.singular_noun(plur), sing))
self.assertEqual(p.inflect('singular_noun(%s)' % plur), sing)
self.assertRaises(BadGenderError, p.gender, 'male')
for sing, plur, gen in (
('it', 'they', 'neuter'),
('she', 'they', 'feminine'),
('he', 'they', 'masculine'),
('they', 'they', 'gender-neutral'),
('she or he', 'they', 'feminine or masculine'),
('he or she', 'they', 'masculine or feminine'),
):
self.assertEqual(p.singular_noun(plur, gender=gen), sing)
)
self.assertEqual(p.inflect("singular_noun('%s')" % plur), sing)
self.assertRaises(BadGenderError, p.gender, "male")
for sing, plur, gen in (
("it", "they", "neuter"),
("she", "they", "feminine"),
("he", "they", "masculine"),
("they", "they", "gender-neutral"),
("she or he", "they", "feminine or masculine"),
("he or she", "they", "masculine or feminine"),
):
self.assertEqual(p.singular_noun(plur, gender=gen), sing)
with self.assertRaises(BadGenderError):
p.singular_noun("cats", gender="unknown gender")
("it", "they"),
("itself", "themselves"),
("its", "theirs"),
("to it", "to them"),
("to itself", "to themselves"),
):
self.assertEqual(
p.singular_noun(plur),
sing,
"singular_noun({}) == {} != {}".format(
plur, p.singular_noun(plur), sing
),
)
self.assertEqual(p.inflect("singular_noun('%s')" % plur), sing)
self.assertRaises(BadGenderError, p.gender, "male")
for sing, plur, gen in (
("it", "they", "neuter"),
("she", "they", "feminine"),
("he", "they", "masculine"),
("they", "they", "gender-neutral"),
("she or he", "they", "feminine or masculine"),
("he or she", "they", "masculine or feminine"),
):
self.assertEqual(p.singular_noun(plur, gender=gen), sing)
with self.assertRaises(BadGenderError):
p.singular_noun("cats", gender="unknown gender")
def _sinoun(self, word, count=None, gender=None):
count = self.get_count(count)
# DEFAULT TO PLURAL
if count == 2:
return word
# SET THE GENDER
try:
if gender is None:
gender = self.thegender
elif gender not in singular_pronoun_genders:
raise BadGenderError
except (TypeError, IndexError):
raise BadGenderError
# HANDLE USER-DEFINED NOUNS
value = self.ud_match(word, self.si_sb_user_defined)
if value is not None:
return value
# HANDLE EMPTY WORD, SINGULAR COUNT AND UNINFLECTED PLURALS
if word == "":
return word
lower_word = word.lower()