@@ -753,3 +753,48 @@ def test_replace_in_all_jsonb_values(self):
753
753
self .assertRegex (test_partner_title .name , pattern_new )
754
754
self .assertRegex (test_partner_title .name , pattern_notouch )
755
755
self .assertNotRegex (test_partner_title .name , pattern_old )
756
+
757
+
758
+ class TestMisc (UnitTestCase ):
759
+ @parametrize (
760
+ [
761
+ ("{a,b}" , ["a" , "b" ]),
762
+ ("head_{a,b}_tail" , ["head_a_tail" , "head_b_tail" ]),
763
+ ("head_only_{a,b}" , ["head_only_a" , "head_only_b" ]),
764
+ ("{a,b}_tail_only" , ["a_tail_only" , "b_tail_only" ]),
765
+ ("{with,more,than,one,comma}" , ["with" , "more" , "than" , "one" , "comma" ]),
766
+ ("head_{one,two,three}_tail" , ["head_one_tail" , "head_two_tail" , "head_three_tail" ]),
767
+ ("same_{a,a}" , ["same_a" , "same_a" ]),
768
+ ("empty_part_{a,}" , ["empty_part_a" , "empty_part_" ]),
769
+ ("empty_part_{,b}" , ["empty_part_" , "empty_part_b" ]),
770
+ ("two_empty_{,}" , ["two_empty_" , "two_empty_" ]),
771
+ ("with_cr\n _{a,b}" , ["with_cr\n _a" , "with_cr\n _b" ]),
772
+ ("with_cr_in_{a\n b,c\n d}_end" , ["with_cr_in_a\n b_end" , "with_cr_in_c\n d_end" ]),
773
+ ]
774
+ )
775
+ def test_expand_braces (self , value , expected ):
776
+ self .assertEqual (util .expand_braces (value ), expected )
777
+
778
+ @parametrize (
779
+ [
780
+ (value ,)
781
+ for value in [
782
+ "" ,
783
+ "no_braces" ,
784
+ "empty_{}" ,
785
+ "one_{item}" ,
786
+ "unclosed_{_brace" ,
787
+ "two_{a,b}_expanses_{x,y}" ,
788
+ # braces into braces
789
+ "{a,{b,c},d}" ,
790
+ "{a,{}" ,
791
+ "{a,b}c}" ,
792
+ "{a,{b,}" ,
793
+ "{{}}" ,
794
+ "{{one}}" ,
795
+ ]
796
+ ]
797
+ )
798
+ def test_expand_braces_failure (self , value ):
799
+ with self .assertRaises (ValueError ):
800
+ util .expand_braces (value )
0 commit comments