Пример #1
0
    def test_cc_example(self):
        """
        Searches for Credit Cards
        """

        easy = Easy() \
                .digit().digit().digit().digit() \
                .then('-') \
                .digit().digit().digit().digit() \
                .then('-') \
                .digit().digit().digit().digit() \
                .then('-') \
                .digit().digit().digit().digit()

        test_s = "4444-5555-6666-7777"
        self.assertTrue(easy.test(test_s))

        test_s = "444-555-666-777"
        self.assertFalse(easy.test(test_s))

        test_s = "Hey Joe! The credit card number for the invoice is 4444-5555-6666-7777. Thanks!"
        self.assertTrue(easy.test(test_s))

        test_s = "Hey JoeBot4444-5555-! Your PIN number is 2222-3333."
        self.assertFalse(easy.test(test_s))
Пример #2
0
    def test_cc_example(self):
        """
        Searches for Credit Cards
        """

        easy = Easy() \
                .digit().digit().digit().digit() \
                .then('-') \
                .digit().digit().digit().digit() \
                .then('-') \
                .digit().digit().digit().digit() \
                .then('-') \
                .digit().digit().digit().digit()

        test_s = "4444-5555-6666-7777"
        self.assertTrue(easy.test(test_s))

        test_s = "444-555-666-777"
        self.assertFalse(easy.test(test_s))

        test_s = "Hey Joe! The credit card number for the invoice is 4444-5555-6666-7777. Thanks!"
        self.assertTrue(easy.test(test_s))

        test_s = "Hey JoeBot4444-5555-! Your PIN number is 2222-3333."
        self.assertFalse(easy.test(test_s))
Пример #3
0
    def test_of_any(self):
        """
        Test ofAny
        """
        easy = Easy() \
                .startOfLine() \
                .exactly(3).ofAny() \
                .endOfLine()

        self.assertTrue(easy.test("abc"))
        self.assertFalse(easy.test("ac"))
Пример #4
0
    def test_of_any(self):
        """
        Test ofAny
        """
        easy = Easy() \
                .startOfLine() \
                .exactly(3).ofAny() \
                .endOfLine()

        self.assertTrue(easy.test("abc"))
        self.assertFalse(easy.test("ac"))
Пример #5
0
    def test_from(self):
        """
        Test asGroup and ofGroup
        """
        easy = Easy() \
                .startOfLine() \
                .exactly(3).of("p").asGroup() \
                .exactly(1).of("q") \
                .exactly(1).ofGroup(1) \
                .endOfLine()

        self.assertTrue(easy.test("pppqppp"))
        self.assertFalse(easy.test("pxpqppp"))
Пример #6
0
    def test_of(self):
        """
        Test of
        """
        easy = Easy() \
                .startOfLine() \
                .exactly(2).of("p p p ") \
                .endOfLine()

        test = "p p p p p p "
        self.assertTrue(easy.test(test))
        test = "p p p p pp"
        self.assertFalse(easy.test(test))
Пример #7
0
    def test_from(self):
        """
        Test asGroup and ofGroup
        """
        easy = Easy() \
                .startOfLine() \
                .exactly(3).of("p").asGroup() \
                .exactly(1).of("q") \
                .exactly(1).ofGroup(1) \
                .endOfLine()

        self.assertTrue(easy.test("pppqppp"))
        self.assertFalse(easy.test("pxpqppp"))
Пример #8
0
    def test_of(self):
        """
        Test of
        """
        easy = Easy() \
                .startOfLine() \
                .exactly(2).of("p p p ") \
                .endOfLine()

        test = "p p p p p p "
        self.assertTrue(easy.test(test))
        test = "p p p p pp"
        self.assertFalse(easy.test(test))
Пример #9
0
    def test_us_phone_numbers(self):
        """
        Searches for US phone numbers.
        """

        easy = Easy() \
                .find('(') \
                .digit().digit().digit() \
                .then(')') \
                .then(' ') \
                .digit().digit().digit() \
                .then('-') \
                .digit().digit().digit().digit() \

        test_s = "Hey Mike, give me a call at (123) 555-1234. Thanks!"
        self.assertTrue(easy.test(test_s))

        test_s = "Hey Joe! The credit card number for the invoice is 4444-5555-6666-7777. Thanks!"
        self.assertFalse(easy.test(test_s))
Пример #10
0
    def test_us_phone_numbers(self):
        """
        Searches for US phone numbers.
        """

        easy = Easy() \
                .find('(') \
                .digit().digit().digit() \
                .then(')') \
                .then(' ') \
                .digit().digit().digit() \
                .then('-') \
                .digit().digit().digit().digit() \

        test_s = "Hey Mike, give me a call at (123) 555-1234. Thanks!"
        self.assertTrue(easy.test(test_s))

        test_s = "Hey Joe! The credit card number for the invoice is 4444-5555-6666-7777. Thanks!"
        self.assertFalse(easy.test(test_s))
Пример #11
0
    def test_names(self):
        """
        Searches for possible names.
        """

        easy = Easy() \
                .upperCaseLetter() \
                .lowerCaseLetters() \
                .then(' ') \
                .upperCaseLetter() \
                .lowerCaseLetters() \

        test_s = "The two rappers who really run the south are Paul Wall and Slim Thug."
        self.assertTrue(easy.test(test_s))

        test_s = "Philadelphia."
        self.assertFalse(easy.test(test_s))

        test_s = "Hey lol this isnt a name. Test."
        self.assertFalse(easy.test(test_s))
Пример #12
0
    def test_names(self):
        """
        Searches for possible names.
        """

        easy = Easy() \
                .upperCaseLetter() \
                .lowerCaseLetters() \
                .then(' ') \
                .upperCaseLetter() \
                .lowerCaseLetters() \

        test_s = "The two rappers who really run the south are Paul Wall and Slim Thug."
        self.assertTrue(easy.test(test_s))

        test_s = "Philadelphia."
        self.assertFalse(easy.test(test_s))

        test_s = "Hey lol this isnt a name. Test."
        self.assertFalse(easy.test(test_s))
Пример #13
0
 def test_easy_test(self):
     easy = Easy().startOfLine().exactly(1).of("p")
     self.assertTrue(easy.test('p'))
     self.assertFalse(easy.test('qp'))
Пример #14
0
 def test_easy_test(self):
     easy = Easy().startOfLine().exactly(1).of("p")
     self.assertTrue(easy.test('p'))
     self.assertFalse(easy.test('qp'))