def test_escrita_campo_num_decimal(self):
        # aceitar somente tipo Decimal
        with self.assertRaises(errors.TipoError):
            self.seg_p.valor_titulo = 10.0
        with self.assertRaises(errors.TipoError):
            self.seg_p.valor_titulo = ''

        # Testa se as casas decimais estao sendo verificadas
        with self.assertRaises(errors.NumDecimaisError):
            self.seg_p.valor_titulo = Decimal('100.2')
        with self.assertRaises(errors.NumDecimaisError):
            self.seg_p.valor_titulo = Decimal('1001')
        with self.assertRaises(errors.NumDecimaisError):
            self.seg_p.valor_titulo = Decimal('1.000')

        # verifica se o numero de digitos esta sendo verificado
        with self.assertRaises(errors.NumDigitosExcedidoError):
            self.seg_p.valor_titulo = Decimal('10000000008100.21')

        # armazemamento correto de um decimal
        self.seg_p.valor_titulo = Decimal('2.13')
        self.assertEqual(self.seg_p.valor_titulo, Decimal('2.13'))
def _testrefastpath(repat):
    """Test if a re pattern can use fast path.

    That is, for every "$A/$B" path the pattern matches, "$A" must also be
    matched,

    Return True if we're sure it is. Return False otherwise.
    """
    # XXX: It's very hard to implement this. These are what need to be
    # supported in production and tests. Very hacky. But we plan to get rid
    # of re matchers eventually.

    # Rules like "(?!experimental/)"
    if repat.startswith("(?!") and repat.endswith(")") and repat.count(")") == 1:
        return True

    # Rules used in doctest
    if repat == "(i|j)$":
        return True

    return False