@@ -161,12 +161,17 @@ def getTuples(queryName, jsonResult, fname):
161161
162162scriptPath = os .path .dirname (sys .argv [0 ])
163163
164+ def copyfile (fromName , toFileHandle ):
165+ with open (os .path .join (scriptPath , fromName ), "r" ) as fromFileHandle :
166+ shutil .copyfileobj (fromFileHandle , toFileHandle )
167+
164168with open (resultQl , "w" ) as f :
165- with open (os .path .join (scriptPath , "testHeader.qlfrag" ), "r" ) as header :
166- shutil .copyfileobj (header , f )
167- f .write (", " .join ('"%s"' % modelSpecRow [0 ].strip () for modelSpecRow in supportModelRows ))
168- with open (os .path .join (scriptPath , "testFooter.qlfrag" ), "r" ) as header :
169- shutil .copyfileobj (header , f )
169+ copyfile ("testHeader.qlfrag" , f )
170+ if len (supportModelRows ) != 0 :
171+ copyfile ("testModelsHeader.qlfrag" , f )
172+ f .write (", " .join ('"%s"' % modelSpecRow [0 ].strip () for modelSpecRow in supportModelRows ))
173+ copyfile ("testModelsFooter.qlfrag" , f )
174+ copyfile ("testFooter.qlfrag" , f )
170175
171176# Make an empty .expected file, since this is an inline-exectations test
172177with open (os .path .join (sys .argv [3 ], "test.expected" ), "w" ):
0 commit comments