@@ -136,10 +136,20 @@ def test_should_match_url(self):
136
136
self .exp = self .v .start_of_line ().then ('http' ).maybe ('s' ).then ('://' ).maybe ('www.' ).word ().then ('.' ).word ().maybe ('/' ).end_of_line ().regex ()
137
137
self .assertRegexpMatches ('https://www.google.com/' , self .exp , 'Not a valid email' )
138
138
139
- def test_should_find_named_groups (self ):
139
+ def test_should_find_number (self ):
140
+ self .exp = self .v .start_of_line ().number ().end_of_line ().regex ()
141
+ self .assertRegexpMatches ('123' , self .exp , 'Number not found' )
142
+
143
+ def test_word_should_find_named_groups (self ):
140
144
name = "Linus Torvalds"
141
145
self .exp = self .v .start_of_line ().word (name = 'first_name' ).then (' ' ).word (name = 'last_name' ).end_of_line ().regex ()
142
146
match = self .exp .match (name )
143
147
self .assertIsNotNone (match )
144
- self .assertTrue (match .group ('first_name' ) == 'Linus' )
145
- self .assertTrue (match .group ('last_name' ) == 'Torvalds' )
148
+ self .assertEquals (match .group ('first_name' ), 'Linus' )
149
+ self .assertEquals (match .group ('last_name' ), 'Torvalds' )
150
+
151
+ def test_number_should_find_named_groups (self ):
152
+ self .exp = self .v .start_of_line ().number ('number' ).end_of_line ().regex ()
153
+ match = self .exp .match ('123' )
154
+ self .assertIsNotNone (match , self .exp .pattern )
155
+ self .assertEquals (match .group ('number' ), '123' )
0 commit comments