@@ -499,6 +499,13 @@ def test_matchwildcard(self):
499499 self .assertTrue (op ('bar' , 'b*r' ), 'Failed matchwildcard.' )
500500 self .assertTrue (op ('bar' , 'b?r' ), 'Failed matchwildcard.' )
501501
502+ # Mixing bytes and strings / unicode should still work
503+ self .assertTrue (op (b'bar' , 'b?r' ), 'Failed matchwildcard.' )
504+ self .assertTrue (op ('bar' , b'b?r' ), 'Failed matchwildcard.' )
505+ self .assertTrue (op (b'bar' , b'b?r' ), 'Failed matchwildcard.' )
506+ self .assertTrue (op (u'bar' , b'b?r' ), 'Failed matchwildcard.' )
507+ self .assertTrue (op (u'bar' , u'b?r' ), 'Failed matchwildcard.' )
508+
502509 self .assertFalse (op ('1' , None ), 'Passed matchwildcard with None as criteria_pattern.' )
503510
504511 def test_matchregex (self ):
@@ -517,13 +524,27 @@ def test_matchregex(self):
517524 string = 'foo\r \n ponies\n bar\n fooooo'
518525 self .assertTrue (op (string , '.*ponies.*' ), 'Failed matchregex.' )
519526
527+ # Mixing bytes and strings / unicode should still work
528+ self .assertTrue (op (b'foo ponies bar' , '.*ponies.*' ), 'Failed matchregex.' )
529+ self .assertTrue (op ('foo ponies bar' , b'.*ponies.*' ), 'Failed matchregex.' )
530+ self .assertTrue (op (b'foo ponies bar' , b'.*ponies.*' ), 'Failed matchregex.' )
531+ self .assertTrue (op (b'foo ponies bar' , u'.*ponies.*' ), 'Failed matchregex.' )
532+ self .assertTrue (op (u'foo ponies bar' , u'.*ponies.*' ), 'Failed matchregex.' )
533+
520534 def test_iregex (self ):
521535 op = operators .get_operator ('iregex' )
522536 self .assertTrue (op ('V1' , 'v1$' ), 'Failed iregex.' )
523537
524538 string = 'fooPONIESbarfooooo'
525539 self .assertTrue (op (string , 'ponies' ), 'Failed iregex.' )
526540
541+ # Mixing bytes and strings / unicode should still work
542+ self .assertTrue (op (b'fooPONIESbarfooooo' , 'ponies' ), 'Failed iregex.' )
543+ self .assertTrue (op ('fooPONIESbarfooooo' , b'ponies' ), 'Failed iregex.' )
544+ self .assertTrue (op (b'fooPONIESbarfooooo' , b'ponies' ), 'Failed iregex.' )
545+ self .assertTrue (op (b'fooPONIESbarfooooo' , u'ponies' ), 'Failed iregex.' )
546+ self .assertTrue (op (u'fooPONIESbarfooooo' , u'ponies' ), 'Failed iregex.' )
547+
527548 def test_iregex_fail (self ):
528549 op = operators .get_operator ('iregex' )
529550 self .assertFalse (op ('V1_foo' , 'v1$' ), 'Passed iregex.' )
@@ -543,6 +564,13 @@ def test_regex(self):
543564 string = 'apple unicorns oranges'
544565 self .assertTrue (op (string , '(ponies|unicorns)' ), 'Failed regex.' )
545566
567+ # Mixing bytes and strings / unicode should still work
568+ self .assertTrue (op (b'apples unicorns oranges' , '(ponies|unicorns)' ), 'Failed regex.' )
569+ self .assertTrue (op ('apples unicorns oranges' , b'(ponies|unicorns)' ), 'Failed regex.' )
570+ self .assertTrue (op (b'apples unicorns oranges' , b'(ponies|unicorns)' ), 'Failed regex.' )
571+ self .assertTrue (op (b'apples unicorns oranges' , u'(ponies|unicorns)' ), 'Failed regex.' )
572+ self .assertTrue (op (u'apples unicorns oranges' , u'(ponies|unicorns)' ), 'Failed regex.' )
573+
546574 string = 'apple unicorns oranges'
547575 self .assertFalse (op (string , '(pikachu|snorlax|charmander)' ), 'Passed regex.' )
548576
@@ -575,6 +603,13 @@ def test_equals_string(self):
575603 self .assertTrue (op ('1' , '1' ), 'Failed equals.' )
576604 self .assertTrue (op ('' , '' ), 'Failed equals.' )
577605
606+ # Mixing bytes and strings / unicode should still work
607+ self .assertTrue (op (b'1' , '1' ), 'Failed equals.' )
608+ self .assertTrue (op ('1' , b'1' ), 'Failed equals.' )
609+ self .assertTrue (op (b'1' , b'1' ), 'Failed equals.' )
610+ self .assertTrue (op (b'1' , u'1' ), 'Failed equals.' )
611+ self .assertTrue (op (u'1' , u'1' ), 'Failed equals.' )
612+
578613 def test_equals_fail (self ):
579614 op = operators .get_operator ('equals' )
580615 self .assertFalse (op ('1' , '2' ), 'Passed equals.' )
@@ -597,6 +632,13 @@ def test_iequals(self):
597632 self .assertTrue (op ('ABC' , 'abc' ), 'Failed iequals.' )
598633 self .assertTrue (op ('AbC' , 'aBc' ), 'Failed iequals.' )
599634
635+ # Mixing bytes and strings / unicode should still work
636+ self .assertTrue (op (b'AbC' , 'aBc' ), 'Failed iequals.' )
637+ self .assertTrue (op ('AbC' , b'aBc' ), 'Failed iequals.' )
638+ self .assertTrue (op (b'AbC' , b'aBc' ), 'Failed iequals.' )
639+ self .assertTrue (op (b'AbC' , u'aBc' ), 'Failed iequals.' )
640+ self .assertTrue (op (u'AbC' , u'aBc' ), 'Failed iequals.' )
641+
600642 def test_iequals_fail (self ):
601643 op = operators .get_operator ('iequals' )
602644 self .assertFalse (op ('ABC' , 'BCA' ), 'Passed iequals.' )
@@ -611,6 +653,13 @@ def test_contains(self):
611653 self .assertTrue (op ('haystackneedle' , 'needle' ))
612654 self .assertTrue (op ('haystack needle' , 'needle' ))
613655
656+ # Mixing bytes and strings / unicode should still work
657+ self .assertTrue (op (b'haystack needle' , 'needle' ))
658+ self .assertTrue (op ('haystack needle' , b'needle' ))
659+ self .assertTrue (op (b'haystack needle' , b'needle' ))
660+ self .assertTrue (op (b'haystack needle' , u'needle' ))
661+ self .assertTrue (op (u'haystack needle' , b'needle' ))
662+
614663 def test_contains_fail (self ):
615664 op = operators .get_operator ('contains' )
616665 self .assertFalse (op ('hasystack needl haystack' , 'needle' ))
@@ -626,6 +675,13 @@ def test_icontains(self):
626675 self .assertTrue (op ('haystackNEEDLE' , 'needle' ))
627676 self .assertTrue (op ('haystack needle' , 'NEEDLE' ))
628677
678+ # Mixing bytes and strings / unicode should still work
679+ self .assertTrue (op (b'haystack needle' , 'NEEDLE' ))
680+ self .assertTrue (op ('haystack needle' , b'NEEDLE' ))
681+ self .assertTrue (op (b'haystack needle' , b'NEEDLE' ))
682+ self .assertTrue (op (b'haystack needle' , u'NEEDLE' ))
683+ self .assertTrue (op (u'haystack needle' , b'NEEDLE' ))
684+
629685 def test_icontains_fail (self ):
630686 op = operators .get_operator ('icontains' )
631687 self .assertFalse (op ('hasystack needl haystack' , 'needle' ))
@@ -641,6 +697,13 @@ def test_ncontains(self):
641697 self .assertTrue (op ('haystackneedle' , 'needlex' ))
642698 self .assertTrue (op ('haystack needle' , 'needlex' ))
643699
700+ # Mixing bytes and strings / unicode should still work
701+ self .assertTrue (op (b'haystack needle' , 'needlex' ))
702+ self .assertTrue (op ('haystack needle' , b'needlex' ))
703+ self .assertTrue (op (b'haystack needle' , b'needlex' ))
704+ self .assertTrue (op (b'haystack needle' , u'needlex' ))
705+ self .assertTrue (op (u'haystack needle' , b'needlex' ))
706+
644707 def test_ncontains_fail (self ):
645708 op = operators .get_operator ('ncontains' )
646709 self .assertFalse (op ('hasystack needle haystack' , 'needle' ))
@@ -667,6 +730,13 @@ def test_startswith(self):
667730 self .assertTrue (op ('hasystack needle haystack' , 'hasystack' ))
668731 self .assertTrue (op ('a hasystack needle haystack' , 'a ' ))
669732
733+ # Mixing bytes and strings / unicode should still work
734+ self .assertTrue (op (b'haystack needle' , 'haystack' ))
735+ self .assertTrue (op ('haystack needle' , b'haystack' ))
736+ self .assertTrue (op (b'haystack needle' , b'haystack' ))
737+ self .assertTrue (op (b'haystack needle' , u'haystack' ))
738+ self .assertTrue (op (u'haystack needle' , b'haystack' ))
739+
670740 def test_startswith_fail (self ):
671741 op = operators .get_operator ('startswith' )
672742 self .assertFalse (op ('hasystack needle haystack' , 'needle' ))
@@ -678,6 +748,13 @@ def test_istartswith(self):
678748 self .assertTrue (op ('haystack needle haystack' , 'HAYstack' ))
679749 self .assertTrue (op ('HAYSTACK needle haystack' , 'haystack' ))
680750
751+ # Mixing bytes and strings / unicode should still work
752+ self .assertTrue (op (b'HAYSTACK needle haystack' , 'haystack' ))
753+ self .assertTrue (op ('HAYSTACK needle haystack' , b'haystack' ))
754+ self .assertTrue (op (b'HAYSTACK needle haystack' , b'haystack' ))
755+ self .assertTrue (op (b'HAYSTACK needle haystack' , u'haystack' ))
756+ self .assertTrue (op (u'HAYSTACK needle haystack' , b'haystack' ))
757+
681758 def test_istartswith_fail (self ):
682759 op = operators .get_operator ('istartswith' )
683760 self .assertFalse (op ('hasystack needle haystack' , 'NEEDLE' ))
@@ -689,6 +766,13 @@ def test_endswith(self):
689766 self .assertTrue (op ('hasystack needle haystackend' , 'haystackend' ))
690767 self .assertTrue (op ('a hasystack needle haystack b' , 'b' ))
691768
769+ # Mixing bytes and strings / unicode should still work
770+ self .assertTrue (op (b'a hasystack needle haystack b' , 'b' ))
771+ self .assertTrue (op ('a hasystack needle haystack b' , b'b' ))
772+ self .assertTrue (op (b'a hasystack needle haystack b' , b'b' ))
773+ self .assertTrue (op (b'a hasystack needle haystack b' , u'b' ))
774+ self .assertTrue (op (u'a hasystack needle haystack b' , b'b' ))
775+
692776 def test_endswith_fail (self ):
693777 op = operators .get_operator ('endswith' )
694778 self .assertFalse (op ('hasystack needle haystackend' , 'haystack' ))
@@ -776,6 +860,11 @@ def test_inside(self):
776860 self .assertFalse (op ('a' , 'bcd' ), 'Should return False' )
777861 self .assertTrue (op ('a' , 'abc' ), 'Should return True' )
778862
863+ # Mixing bytes and strings / unicode should still work
864+ self .assertTrue (op (b'a' , 'abc' ), 'Should return True' )
865+ self .assertTrue (op ('a' , b'abc' ), 'Should return True' )
866+ self .assertTrue (op (b'a' , b'abc' ), 'Should return True' )
867+
779868 def test_ninside (self ):
780869 op = operators .get_operator ('ninside' )
781870 self .assertFalse (op ('a' , None ), 'Should return False' )
0 commit comments