Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_millfn(self):
p = inflect.engine()
millfn = p.millfn
self.assertEqual(millfn(1), ' thousand')
self.assertEqual(millfn(2), ' million')
self.assertEqual(millfn(3), ' billion')
self.assertEqual(millfn(0), '')
self.assertEqual(millfn(11), ' decillion')
inflect.STDOUT_ON = False
self.assertRaises(NumOutOfRangeError, millfn, 12)
inflect.STDOUT_ON = True
self.assertEqual(numwords('120', group=2),
'twelve, zero')
self.assertEqual(numwords('120', group=2, zero='oh', one='unity'),
'twelve, oh')
# TODO: ignoring 'one' param with group=2
self.TODO(numwords('101', group=2, zero='oh', one='unity'),
'ten, unity',
'ten, one')
self.assertEqual(numwords('555_1202', group=1, zero='oh'),
'five, five, five, one, two, oh, two')
self.assertEqual(numwords('555_1202', group=1, one='unity'),
'five, five, five, unity, two, zero, two')
self.assertEqual(numwords('123.456', group=1, decimal='mark', one='one'),
'one, two, three, mark, four, five, six')
inflect.STDOUT_ON = False
self.assertRaises(BadChunkingOptionError,
numwords, '1234', group=4)
inflect.STDOUT_ON = True
self.assertEqual(p.ud_match("studio", p.pl_sb_user_defined), "studii")
p.defnoun("aviatrix", "aviatrices")
self.assertEqual(p.plural("aviatrix"), "aviatrices")
self.assertEqual(p.ud_match("aviatrix", p.pl_sb_user_defined), "aviatrices")
p.defnoun("aviatrix", "aviatrixes")
self.assertEqual(p.plural("aviatrix"), "aviatrixes")
self.assertEqual(p.ud_match("aviatrix", p.pl_sb_user_defined), "aviatrixes")
p.defnoun("aviatrix", None)
self.assertEqual(p.plural("aviatrix"), "aviatrices")
self.assertEqual(p.ud_match("aviatrix", p.pl_sb_user_defined), None)
p.defnoun("(cat)", r"$1s")
self.assertEqual(p.plural("cat"), "cats")
inflect.STDOUT_ON = False
self.assertRaises(inflect.BadUserDefinedPatternError, p.defnoun, "(??", None)
inflect.STDOUT_ON = True
p.defnoun(None, "") # check None doesn't crash it
# defverb
p.defverb("will", "shall", "will", "will", "will", "will")
self.assertEqual(p.ud_match("will", p.pl_v_user_defined), "will")
self.assertEqual(p.plural("will"), "will")
# TODO: will -> shall. Tests below fail
self.TODO(p.compare("will", "shall"), "s:p")
self.TODO(p.compare_verbs("will", "shall"), "s:p")
# defadj
p.defadj("hir", "their")
self.assertEqual(p.plural("hir"), "their")
p.defnoun("aviatrix", "aviatrices")
self.assertEqual(p.plural("aviatrix"), "aviatrices")
self.assertEqual(p.ud_match("aviatrix", p.pl_sb_user_defined), "aviatrices")
p.defnoun("aviatrix", "aviatrixes")
self.assertEqual(p.plural("aviatrix"), "aviatrixes")
self.assertEqual(p.ud_match("aviatrix", p.pl_sb_user_defined), "aviatrixes")
p.defnoun("aviatrix", None)
self.assertEqual(p.plural("aviatrix"), "aviatrices")
self.assertEqual(p.ud_match("aviatrix", p.pl_sb_user_defined), None)
p.defnoun("(cat)", r"$1s")
self.assertEqual(p.plural("cat"), "cats")
inflect.STDOUT_ON = False
self.assertRaises(inflect.BadUserDefinedPatternError, p.defnoun, "(??", None)
inflect.STDOUT_ON = True
p.defnoun(None, "") # check None doesn't crash it
# defverb
p.defverb("will", "shall", "will", "will", "will", "will")
self.assertEqual(p.ud_match("will", p.pl_v_user_defined), "will")
self.assertEqual(p.plural("will"), "will")
# TODO: will -> shall. Tests below fail
self.TODO(p.compare("will", "shall"), "s:p")
self.TODO(p.compare_verbs("will", "shall"), "s:p")
# defadj
p.defadj("hir", "their")
self.assertEqual(p.plural("hir"), "their")
self.assertEqual(p.ud_match("hir", p.pl_adj_user_defined), "their")
def test_print(self):
inflect.STDOUT_ON = True
inflect.print3('') # make sure it doesn't crash
inflect.STDOUT_ON = False
'twelve, oh')
# TODO: ignoring 'one' param with group=2
self.TODO(numwords('101', group=2, zero='oh', one='unity'),
'ten, unity',
'ten, one')
self.assertEqual(numwords('555_1202', group=1, zero='oh'),
'five, five, five, one, two, oh, two')
self.assertEqual(numwords('555_1202', group=1, one='unity'),
'five, five, five, unity, two, zero, two')
self.assertEqual(numwords('123.456', group=1, decimal='mark', one='one'),
'one, two, three, mark, four, five, six')
inflect.STDOUT_ON = False
self.assertRaises(BadChunkingOptionError,
numwords, '1234', group=4)
inflect.STDOUT_ON = True