Ejemplo n.º 1
0
 def test_singular_wrong_person(self):
     with self.assertRaises(ValueError):
         Adjective("our").singular(5)
     with self.assertRaises(ValueError):
         Adjective("our").singular("hello")
     with self.assertRaises(ValueError):
         Adjective("our").singular("first")
Ejemplo n.º 2
0
 def test_plural_wrong_person(self):
     with self.assertRaises(ValueError):
         Adjective("our").plural(5)
     with self.assertRaises(ValueError):
         Adjective("our").plural("hello")
     with self.assertRaises(ValueError):
         Adjective("our").plural("first")
Ejemplo n.º 3
0
 def test_as_regex(self):
     adj = Adjective("our")
     pattern = adj.as_regex()
     self.assertEqual(
         pattern, re.compile("our|my", re.IGNORECASE),
         "Check whether as_regex produces a compiled regex object correctly."
     )
Ejemplo n.º 4
0
 def test_possessive_to_plural(self):
     for test_case in self.test_possessive_to_plural_args:
         with self.subTest():
             # Add default `kwargs` if it doesn't exist in test_case yet
             test_case = {**{"kwargs": {}}, **test_case}
             test_case[
                 "desc"] = f"Adjective({repr(test_case['in'])}).plural({test_case['kwargs']}) => {repr(test_case['out'])}"
             adj = Adjective(test_case["in"])
             self.assertEqual(adj.plural(**test_case["kwargs"]),
                              test_case["out"], test_case["desc"])
Ejemplo n.º 5
0
 def test_to_superlative(self):
     for adjective, _, superlative in self.test_comparative_superlative_args:
         with self.subTest():
             test_case = {
                 "in": adjective,
                 "out": superlative,
                 "desc":
                 f"Adjective({repr(adjective)}).superlative() => {repr(superlative)}",
                 "kwargs": {}
             }
             adj = Adjective(test_case["in"])
             self.assertEqual(adj.superlative(**test_case["kwargs"]),
                              test_case["out"], test_case["desc"])
Ejemplo n.º 6
0
 def test_to_classical_plural(self):
     for adjective in self.adjectives:
         with self.subTest():
             test_case = {
                 "in": adjective,
                 "out": adjective,
                 "desc":
                 f"Adjective({repr(adjective)}).classical().plural() => {repr(adjective)}",
                 "kwargs": {}
             }
             adj = Adjective(test_case["in"])
             self.assertEqual(adj.classical().plural(**test_case["kwargs"]),
                              test_case["out"], test_case["desc"])
Ejemplo n.º 7
0
 def test_to_singular(self):
     for adjective in self.adjectives:
         with self.subTest():
             test_case = {
                 "in": adjective,
                 "out": adjective,
                 "desc":
                 f"Adjective({repr(adjective)}).singular() => {repr(adjective)}",
                 "kwargs": {}
             }
             adj = Adjective(test_case["in"])
             self.assertEqual(adj.singular(**test_case["kwargs"]),
                              test_case["out"], test_case["desc"])
Ejemplo n.º 8
0
 def test_from_super_to_super(self):
     superlative_exceptions = ["best", "worst", "furthest", "most"]
     for superlative in superlative_exceptions:
         with self.subTest():
             test_case = {
                 "in": superlative,
                 "out": superlative,
                 "desc":
                 f"Adjective({repr(superlative)}).superlative() => {repr(superlative)}",
                 "kwargs": {}
             }
             adj = Adjective(test_case["in"])
             self.assertEqual(adj.superlative(**test_case["kwargs"]),
                              test_case["out"], test_case["desc"])
Ejemplo n.º 9
0
 def test_from_comp_to_comp(self):
     comparative_exceptions = ["better", "worse", "further", "more"]
     for comparative in comparative_exceptions:
         with self.subTest():
             test_case = {
                 "in": comparative,
                 "out": comparative,
                 "desc":
                 f"Adjective({repr(comparative)}).comparative() => {repr(comparative)}",
                 "kwargs": {}
             }
             adj = Adjective(test_case["in"])
             self.assertEqual(adj.comparative(**test_case["kwargs"]),
                              test_case["out"], test_case["desc"])
Ejemplo n.º 10
0
 def test_adjective_to_plural(self):
     for test_case in self.test_args:
         with self.subTest():
             # Expand test_case with default cases, if optional keys are not provided
             test_case = {
                 **test_case,
                 **{
                     "desc": f"plural({repr(test_case['in'])}) => {repr(test_case['out'])}",
                     "kwargs": {}
                 }
             }
             self.assertEqual(
                 Adjective(test_case["in"]).plural(**test_case["kwargs"]),
                 test_case["out"], test_case["desc"])
Ejemplo n.º 11
0
 def test_empty(self):
     adj = Adjective("")
     adj.is_singular()
     adj.is_plural()
     adj.singular()
     adj.plural()
     adj.comparative()
     adj.superlative()
Ejemplo n.º 12
0
 def test_classical(self):
     adj = Adjective("our")
     self.assertEqual(
         adj, adj.classical(),
         "Check whether Adjective(...) = Adjective(...).classical()")
Ejemplo n.º 13
0
 def test_is_adj(self):
     adj = Adjective("our")
     self.assertFalse(adj.is_verb())
     self.assertFalse(adj.is_noun())
     self.assertTrue(adj.is_adj())