@@ -168,19 +168,53 @@ def test_script_custom(command):
168168
169169@pytest .mark .parametrize ("command" , test_commands )
170170def test_add_preamble (command ):
171+
171172 PREAMBLE_TEXT = """
172173# this is some test code
173174# to be added to the file
174175
175176
176177# let's see if it works
177- """
178178
179- command += ' --preamble "' + PREAMBLE_TEXT + '"'
180- stdout = execute_test (command )
179+
180+ """
181+ stdout = execute_test (command + ' --preamble "' + PREAMBLE_TEXT + '"' )
181182 assert "let's see if it works" in stdout
182183
183184
185+ @pytest .mark .parametrize ("command" , test_commands )
186+ def test_add_trim_preamble (command ):
187+
188+ def trim_header (line_string ):
189+ """remove the quoted command and everything from the first class declaration onwards"""
190+ lines = line_string .splitlines ()
191+ start = 0
192+ end = 0
193+ line_no = 0
194+ for l in lines :
195+ if l .startswith ('"""' ):
196+ start = line_no
197+ if l .startswith ('class ' ):
198+ end = line_no
199+ break
200+ line_no += 1
201+
202+ return lines [start :end ]
203+
204+ expected_result = execute_test (command )
205+
206+ BLANK_SPACE = """
207+
208+
209+
210+
211+ """
212+ # ensure blank space does not get propagated
213+ stdout = execute_test (command + ' --preamble "' + BLANK_SPACE + '"' )
214+
215+ assert trim_header (expected_result ) == trim_header (stdout )
216+
217+
184218wrong_arguments_commands = [
185219 pytest .param (f"""{ executable } -l Model items "{ test_data_path / 'photos.json' } " \
186220 -l Model - "{ test_data_path / 'users.json' } " """ , id = "duplicate_name" ),
0 commit comments