File tree Expand file tree Collapse file tree 2 files changed +40
-6
lines changed Expand file tree Collapse file tree 2 files changed +40
-6
lines changed Original file line number Diff line number Diff line change @@ -294,11 +294,13 @@ def split_into_chunks(code):
294
294
chunk = ""
295
295
for line in code .splitlines ():
296
296
if line .strip () == "[...]" :
297
- yield chunk
298
- chunk = ""
297
+ if chunk :
298
+ yield chunk
299
+ chunk = ""
299
300
elif line .startswith ("[...]" ):
300
- yield chunk
301
- chunk = ""
301
+ if chunk :
302
+ yield chunk
303
+ chunk = ""
302
304
elif line .endswith ("[...]" ):
303
305
linestart , _ , _ = line .partition ("[...]" )
304
306
chunk += linestart
Original file line number Diff line number Diff line change 6
6
7
7
from book_parser import CodeListing
8
8
from sourcetree import (
9
- BOOTSTRAP_WGET ,
10
9
ApplyCommitException ,
11
10
Commit ,
12
11
SourceTree ,
@@ -824,7 +823,6 @@ def method1(self):
824
823
with self .assertRaises (ApplyCommitException ):
825
824
check_chunks_against_future_contents (code , future_contents )
826
825
827
-
828
826
def test_leading_blank_lines_in_listing_are_ignored (self ):
829
827
code = dedent (
830
828
"""
@@ -844,6 +842,40 @@ def method1(self):
844
842
).strip ()
845
843
check_chunks_against_future_contents (code , future_contents ) # should not raise
846
844
845
+ def test_thing (self ):
846
+ code = dedent (
847
+ """
848
+ [...]
849
+ item.save()
850
+
851
+ return render(
852
+ request,
853
+ "home.html",
854
+ {"new_item_text": item.text},
855
+ )
856
+ """
857
+ )
858
+ future_contents = dedent (
859
+ """
860
+ from django.shortcuts import render
861
+ from lists.models import Item
862
+
863
+
864
+ def home_page(request):
865
+ item = Item()
866
+ item.text = request.POST.get("item_text", "")
867
+ item.save()
868
+
869
+ return render(
870
+ request,
871
+ "home.html",
872
+ {"new_item_text": item.text},
873
+ )
874
+ """
875
+ ).strip ()
876
+ check_chunks_against_future_contents (code , future_contents ) # should not raise
877
+
878
+
847
879
def test_trailing_blank_lines_in_listing_are_ignored (self ):
848
880
code = dedent (
849
881
"""
You can’t perform that action at this time.
0 commit comments