File tree Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -103,10 +103,11 @@ def matches(self,
103103 shlex .quote (template ), 'foo' )
104104 cmd_s = ' ' .join (cmd )
105105
106- jsn = json .loads (self .call (cmd_s , text = source ))
107- jsn = jsn ['matches' ]
108- for jsn_match in jsn :
109- yield Match .from_dict (jsn_match )
106+ jsn = json .loads (self .call (cmd_s , text = source ) or 'null' )
107+ if jsn is not None :
108+ jsn = jsn ['matches' ]
109+ for jsn_match in jsn :
110+ yield Match .from_dict (jsn_match )
110111
111112 def rewrite (self ,
112113 source : str ,
Original file line number Diff line number Diff line change @@ -18,6 +18,12 @@ def test_match(comby):
1818 assert len (matches ) == 1
1919 print (matches [0 ])
2020
21+ def test_no_match (comby ):
22+ source = "foo"
23+ template = "bar"
24+ matches = list (comby .matches (source , template ))
25+ print (matches )
26+ assert len (matches ) == 0
2127
2228def test_rewrite (comby ):
2329 source = "print('hello world')"
You can’t perform that action at this time.
0 commit comments