Ejemplo n.º 1
0
class TestText(EasyRECase, TestCase):

    AUTO_TEST_RES = [Text('def'), Text('+'), Text('*'), Text('.')]
    AUTO_TEST_MATCHES = [['def'], ['+'], ['*'], ['.']]
    AUTO_TEST_NOMATCH = [['abcd'], ['++'], ['**'], ['.q']]

    def test_matches(self):
        self.matches(Text('def'), 'def')
        self.doesnt_match(Text('def'), 'abcdefghi')
        self.matches(Text('def'), 'defghi')
        self.doesnt_match(Text('def'), 'abcdef')
        self.doesnt_match(Text('def'), 'xyz')

    def test_searches(self):
        self.searchs(Text('def'), 'def')
        self.searchs(Text('def'), 'abcdefghi')
        self.searchs(Text('def'), 'defghi')
        self.searchs(Text('def'), 'abcdef')
        self.doesnt_search(Text('def'), 'xyz')

    def test_exactly_matches(self):
        self.exactly_matches(Text('def'), 'def')
        self.doesnt_exactly_match(Text('def'), 'abcdef')
        self.doesnt_exactly_match(Text('def'), 'defghi')
        self.doesnt_exactly_match(Text('def'), 'abcdefghi')
Ejemplo n.º 2
0
class TestPeriod(EasyRECase, TestCase):
    AUTO_TEST_RES = [Text('.')]

    AUTO_TEST_MATCHES = [['.']]
    AUTO_TEST_NOMATCH = [['x']]
Ejemplo n.º 3
0
# https://www.ietf.org/rfc/rfc5322.html#page-14
QText = ObsQText | CharacterRange(('\x21', '\x5b'), ('\x5d', '\x7f'))

# https://www.ietf.org/rfc/rfc5322.html#page-11
QuotedPair = CharacterRange(
    ('\x01', '\x09')) | CharacterSet('\x0b\x0c') | CharacterRange(
        ('\x0e', '\x7f'))

# https://www.ietf.org/rfc/rfc5322.html#page-13
AText = CharacterSet(ascii_lowercase + digits + '!#$%&\'*+=?^_`{|}~-')

Name = AText.many(1) + ('.' + AText.many(1)).many()

# https://www.ietf.org/rfc/rfc5322.html#page-14
QuotedString = '"' + (QText | (Text("\\") + QuotedPair)).many() + Text('"')

# Includes dot-atom and dot-atom text from https://www.ietf.org/rfc/rfc5322.html#page-13
Domain = AlphaNum + ((AlphaNum | '-').many() + AlphaNum).maybe()
FQDN = (Domain + ".").many(1) + Domain

IP = NumericRange(0, 255)

# https://www.ietf.org/rfc/rfc5322.html#page-18
DText = ObsQText | CharacterRange(('\x21', '\x5a'), ('\x5e', '\x7f'))

# https://www.ietf.org/rfc/rfc5322.html#section-4.4
ObsRoute = '[' + ((AlphaNum + '-').many() + AlphaNum) + \
    ':' + (DText | ('\\' + QuotedPair)).many() + ']'
ObsDomain = (IP + '.') * 3 + (IP | ObsRoute)
Ejemplo n.º 4
0
class TestTextRAdd(EasyRECase, TestCase):
    AUTO_TEST_RES = ['a' + Text('b')]

    AUTO_TEST_MATCHES = [['ab']]
    AUTO_TEST_NOMATCH = [['ba']]
Ejemplo n.º 5
0
class TestTextAdd(EasyRECase, TestCase):
    AUTO_TEST_RES = [Text('a') + 'b']

    AUTO_TEST_MATCHES = [['ab']]
    AUTO_TEST_NOMATCH = [['ba']]
Ejemplo n.º 6
0
 def test_exactly_matches(self):
     self.exactly_matches(Text('def'), 'def')
     self.doesnt_exactly_match(Text('def'), 'abcdef')
     self.doesnt_exactly_match(Text('def'), 'defghi')
     self.doesnt_exactly_match(Text('def'), 'abcdefghi')
Ejemplo n.º 7
0
 def test_searches(self):
     self.searchs(Text('def'), 'def')
     self.searchs(Text('def'), 'abcdefghi')
     self.searchs(Text('def'), 'defghi')
     self.searchs(Text('def'), 'abcdef')
     self.doesnt_search(Text('def'), 'xyz')
Ejemplo n.º 8
0
 def test_matches(self):
     self.matches(Text('def'), 'def')
     self.doesnt_match(Text('def'), 'abcdefghi')
     self.matches(Text('def'), 'defghi')
     self.doesnt_match(Text('def'), 'abcdef')
     self.doesnt_match(Text('def'), 'xyz')