File tree Expand file tree Collapse file tree 2 files changed +221
-118
lines changed
Expand file tree Collapse file tree 2 files changed +221
-118
lines changed Original file line number Diff line number Diff line change @@ -368,7 +368,7 @@ def test_array_multiline_modify():
368368def test_append_to_empty_array ():
369369 doc = parse ("x = [ ]" )
370370 doc ["x" ].append ("a" )
371- assert doc .as_string () == 'x = [ "a" ]'
371+ assert doc .as_string () == 'x = ["a" ]'
372372 doc = parse ("x = [\n ]" )
373373 doc ["x" ].append ("a" )
374374 assert doc .as_string () == 'x = [\n "a"\n ]'
@@ -410,6 +410,8 @@ def test_modify_array_with_comment():
410410 2
411411]"""
412412 )
413+ doc ["x" ].pop (0 )
414+ assert doc .as_string () == "x = [\n 2\n ]"
413415
414416
415417def test_append_to_multiline_array_with_comment ():
@@ -432,14 +434,25 @@ def test_append_to_multiline_array_with_comment():
432434 2,
433435 3,
434436]
437+ """
438+ )
439+ assert doc ["x" ].pop () == 3
440+ assert (
441+ doc .as_string ()
442+ == """\
443+ x = [
444+ # Here is a comment
445+ 1,
446+ 2,
447+ ]
435448"""
436449 )
437450
438451
439452def test_append_dict_to_array ():
440- doc = parse ("x = [ ]" )
453+ doc = parse ("x = []" )
441454 doc [
"x" ].
append ({
"name" :
"John Doe" ,
"email" :
"[email protected] " })
442- expected = 'x = [ {name = "John Doe",email = "[email protected] "} ]' 455+ expected = 'x = [{name = "John Doe",email = "[email protected] "}]' 443456 assert doc .as_string () == expected
444457 # Make sure the produced string is valid
445458 assert parse (doc .as_string ()) == doc
@@ -469,7 +482,7 @@ def test_array_add_line():
469482 == """[
470483 1, 2, 3, # Line 1
471484 4, 5, 6, # Line 2
472- 7, 8
485+ 7, 8,
473486]"""
474487 )
475488
You can’t perform that action at this time.
0 commit comments