Exemplo n.º 1
0
 def test_Pred_from_string(self):
     """
     Pred.from_string should normalise the string as necessary
     """
     cat_pred = RealPred.from_normalised_string('_cat_n_1')
     self.assertEqual(Pred.from_string('_cat_n_1_rel'), cat_pred)
     self.assertEqual(Pred.from_string('"_cat_n_1_rel"'), cat_pred)
     self.assertEqual(Pred.from_string('_CAT_N_1_REL'), cat_pred)
     
     the_pred = GPred.from_normalised_string('the')
     self.assertEqual(Pred.from_string('the_rel'), the_pred)
     self.assertEqual(Pred.from_string('"the_rel"'), the_pred)
     self.assertEqual(Pred.from_string('THE_REL'), the_pred)
Exemplo n.º 2
0
    def test_Pred_from_normalised_string(self):
        """
        Pred.from_normalised_string should instantiate RealPreds or GPreds
        depending on whether there is a leading underscore
        """
        # Check the preds are of the right type
        cat_pred = Pred.from_normalised_string('_cat_n_1')
        the_pred = Pred.from_normalised_string('the_q')
        self.assertIsInstance(cat_pred, RealPred)
        self.assertIsInstance(the_pred, GPred)

        # Check the preds are the equivalent to initialising directly 
        cat_realpred = RealPred.from_normalised_string('_cat_n_1')
        the_gpred = GPred.from_normalised_string('the_q')
        self.assertEqual(cat_pred, cat_realpred)
        self.assertEqual(the_pred, the_gpred)
Exemplo n.º 3
0
    def test_Pred_from_normalised_string(self):
        """
        Pred.from_normalised_string should instantiate RealPreds or GPreds
        depending on whether there is a leading underscore
        """
        # Check the preds are of the right type
        cat_pred = Pred.from_normalised_string('_cat_n_1')
        the_pred = Pred.from_normalised_string('the_q')
        self.assertIsInstance(cat_pred, RealPred)
        self.assertIsInstance(the_pred, GPred)

        # Check the preds are the equivalent to initialising directly 
        cat_realpred = RealPred.from_normalised_string('_cat_n_1')
        the_gpred = GPred.from_normalised_string('the_q')
        self.assertEqual(cat_pred, cat_realpred)
        self.assertEqual(the_pred, the_gpred)
Exemplo n.º 4
0
 def test_Pred_from_string(self):
     """
     Pred.from_string should normalise the string as necessary
     """
     cat_pred = RealPred.from_normalised_string('_cat_n_1')
     self.assertEqual(Pred.from_string('_cat_n_1_rel'), cat_pred)
     self.assertEqual(Pred.from_string('"_cat_n_1_rel"'), cat_pred)
     with self.assertRaises(Warning):
         warnings.simplefilter('error')
         self.assertEqual(Pred.from_string('_CAT_N_1_REL'), cat_pred)
     warnings.resetwarnings()
     
     the_pred = GPred.from_normalised_string('the')
     self.assertEqual(Pred.from_string('the_rel'), the_pred)
     self.assertEqual(Pred.from_string('"the_rel"'), the_pred)
     with self.assertRaises(Warning):
         warnings.simplefilter('error')
         self.assertEqual(Pred.from_string('THE_REL'), the_pred)
     warnings.resetwarnings()