
    hIP                         S r SSKrSSKrSSKJrJrJrJr   " S S5      r " S S5      r	 " S	 S
5      r
 " S S5      r " S S5      r " S S5      r " S S5      rSr " S S5      rg)z
comment testing is all about roundtrips
these can be done in the "old" way by creating a file.data and file.roundtrip
but there is little flexibility in doing that

but some things are not easily tested, eog. how a
roundtrip changes

    N   )
round_tripdedentround_trip_loadround_trip_dumpc                       \ rS rSrS rS rS rS rS rS r	S r
S	 rS
 rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rSrg)TestComments   c                     Sn[        USS9  [        R                  " [        5         [        USS9  SSS5        g! , (       d  f       g= f)zvnot excluding comments caused some problems if at the end of
the file without a newline. First error, then included   z        - europe: 10 # abc
)extraza
N)r   pytestraisesAssertionError)selfxs     _/home/james-whalen/.local/lib/python3.13/site-packages/srsly/tests/ruamel_yaml/test_comments.pytest_no_end_of_file_eol$TestComments.test_no_end_of_file_eol   s5    1D!]]>*q& +**s	   ;
A	c                     [        S5        g )Nz[
        - europe: 10
        - usa:
          - ohio: 2
          - california: 9
        r   r   s    r   test_no_commentsTestComments.test_no_comments       	
    c                     [        S5        g )Nzs
        a: 1
        b: 2
        c: 3
        b1: 2
        b2: 2
        d: 4
        e: 5
        f: 6
        r   r   s    r   test_round_trip_ordering%TestComments.test_round_trip_ordering'       		
r   c                     [        S5        g )Nze
        - europe: 10 # top
        - usa:
          - ohio: 2
          - california: 9 # o
        r   r   s    r   test_complexTestComments.test_complex5   r   r   c                      Sn[        US5        g )Nz5        # comment
        scalar
        ...
        zscalar
...
r   r   ss     r   test_droppedTestComments.test_dropped?   s    
 	1o&r   c                     [        S5        g )Nz
        # C start a
        # C start b
        abc: 1
        ghi: 2
        klm: 3
        # C end a
        # C end b
        r   r   s    r   test_main_mapping_begin_end(TestComments.test_main_mapping_begin_endG       
	
r   c                 T    Sn[        U5      n[        USS9nU[        S5      :X  d   eg )NzM        a:
          b:     # comment 1
            c: 1 # comment 2
           indentzQ        a:
            b:   # comment 1
                c: 1 # comment 2
        )r   r   r   )r   r   dys       r   test_reindentTestComments.test_reindentT   s?    
 AAa(F
 
 	
 
r   c                     [        S5        g )Nz
        # C start a
        # C start b
        abc: 1      # abc comment
        ghi: 2
        klm: 3      # klm comment
        # C end a
        # C end b
        r   r   s    r   &test_main_mapping_begin_end_items_post3TestComments.test_main_mapping_begin_end_items_postd   r,   r   c                     [        S5        g )Nz
        # C start a
        # C start b
        - abc
        - ghi
        - klm
        # C end a
        # C end b
        r   r   s    r   test_main_sequence_begin_end)TestComments.test_main_sequence_begin_endq   r,   r   c                     [        S5        g )Nz
        # C start a
        # C start b
        - abc      # abc comment
        - ghi
        - klm      # klm comment
        # C end a
        # C end b
        r   r   s    r   'test_main_sequence_begin_end_items_post4TestComments.test_main_sequence_begin_end_items_post~   r,   r   c                     [        S5        g )Nz
        # C start a
        # C start b
        abc: 1
        ghi: 2
        klm:
          3a: alpha
          3b: beta   # it is all greek to me
        # C end a
        # C end b
        r   r   s    r   #test_main_mapping_begin_end_complex0TestComments.test_main_mapping_begin_end_complex   s    
	
r   c                     Sn[        USSS9  g )Nz        hr: # 1998 hr ranking
          - Mark McGwire
          - Sammy Sosa
        rbi:
          # 1998 rbi ranking
          - Sammy Sosa
          - Ken Griffey
        r.      r0   block_seq_indentr   r%   s     r   test_09TestComments.test_09   s     	1Q3r   c                     [        S5        g )Nz
        hr: # 1998 hr ranking
        - Mark McGwire
        - Sammy Sosa
        rbi:
          # 1998 rbi ranking
        - Sammy Sosa
        - Ken Griffey
        r   r   s    r   test_09aTestComments.test_09a   r,   r   c                     [        S5        g )NzE
        abc: 1
        # C 3a
        # C 3b
        ghi: 2
        r   r   s    r   test_simple_map_middle_comment+TestComments.test_simple_map_middle_comment   r   r   c                     [        S5        g )Nz`
        map1: # comment 1
          # comment 2
          map2:
            key1: val1
        r   r   s    r   test_map_in_map_0TestComments.test_map_in_map_0   r   r   c                     [        S5        g )NzT
        map1:
          # comment 1
          map2:
            key1: val1
        r   r   s    r   test_map_in_map_1TestComments.test_map_in_map_1   s    	
r   c                     [        S5        g )Nz
        args:
          username: anthon
          passwd: secret
          fullname: Anthon van der Neut
          tmux:
            session-name: test
          loop:
            wait: 10
        r   r   s    r   test_application_arguments'TestComments.test_application_arguments   s    		
r   c                     Sn[        U5      nSUS   S'   UR                  SS5      n[        U5      [        U5      :X  d   eg )Nz
        args:
          username: anthon          # name
          passwd: secret            # password
          fullname: Anthon van der Neut
          tmux:
            session-name: test
          loop:
            wait: 10
        zdeleted passwordargspasswdz: secret          z: deleted password)r   replacer   r   )r   r   datas      r   test_substituteTestComments.test_substitute   sL    	 q!!3VXII*,@At$q	111r   c                     [        S5        g )Nz
        !!set
        # the beginning
        ? a
        # next one is B (lowercase)
        ? b  #  You see? Promised you.
        ? c
        # this is the end
        r   r   s    r   test_set_commentTestComments.test_set_comment   r,   r   c                     [        S5        g )Nzd
        !!omap
        - a: 1
        - b: 2  # two
        - c: 3  # three
        - d: 4
        r   r   s    r   test_omap_comment_roundtrip(TestComments.test_omap_comment_roundtrip       	
r   c                     [        S5        g )Nzw
        !!omap
        - a: 1
        - b: 2  # two
        - c: 3  # three
        # last one
        - d: 4
        r   r   s    r   'test_omap_comment_roundtrip_pre_comment4TestComments.test_omap_comment_roundtrip_pre_comment
  s    		
r   c                     [        S5        g )Nu  
        verbosity: 1                  # 0 is minimal output, -1 none
        base_url: http://gopher.net
        special_indices: [1, 5, 8]
        also_special:
        - a
        - 19
        - 32
        asia and europe: &asia_europe
          Turkey: Ankara
          Russia: Moscow
        countries:
          Asia:
            <<: *asia_europe
            Japan: Tokyo # 東京
          Europe:
            <<: *asia_europe
            Spain: Madrid
            Italy: Rome
        r   r   s    r   test_non_asciiTestComments.test_non_ascii  s    	
r   c                     SS K n[        S5      n[        U5      nUR                  R                  nS H%  nUR                  R                  USXES9nXb:X  a  M%   e   g Nr   zG        ab:
        - x  # comment
        - y  # more comment
        )TFF)default_flow_styleDumperallow_unicodesrsly.ruamel_yamlr   r   ruamel_yamlRoundTripDumperdumpr   srslyr   rZ   dumperutfr2   s          r   test_dump_utf8TestComments.test_dump_utf8.  h     
 q!""22 C!!&&v ' A 6M6	 !r   c                     SS K n[        S5      n[        U5      nUR                  R                  nS H%  nUR                  R                  USXES9nXb:X  a  M%   e   g rk   ro   rt   s          r   test_dump_unicode_utf8#TestComments.test_dump_unicode_utf8@  rz   r   c                     Sn[        U5      nUR                  / SQSS9S:X  d   e[        R                  " [        5         UR                  / SQ5      S:H    S S S 5        g ! , (       d  f       g = f)Nzq        a:
        - b:
          c: 42
        - d:
            f: 196
          e:
            g: 3.14
        )ar   r1   fT)list_ok   )r   mlgetr   r   r   )r   r   r1   s      r   test_mlget_00TestComments.test_mlget_00R  s[     Aww)4w8C???]]>*GG&'3. +**s    A  
A. N)__name__
__module____qualname____firstlineno__r   r   r   r"   r'   r*   r3   r6   r9   r<   r?   rE   rH   rK   rN   rQ   rT   r[   r^   ra   re   rh   rx   r|   r   __static_attributes__r   r   r   r	   r	      s    '


'

 




4


	

2"
	



0$$/r   r	   c                   R    \ rS rSrSr\S 5       rS rS rS r	S r
S rS	 rS
 rSrg)TestInsertPopListib  zolist insertion is more complex than dict insertion, as you
need to move the values to subsequent keys on insertc                     g)Nz        ab:
        - a      # a
        - b      # b
        - c
        - d      # d

        de:
        - 1
        - 2
        r   r   s    r   insTestInsertPopList.insf  s    
r   c                     [        U R                  5      nUS   R                  SS5        [        USS9nU[	        S5      :X  d   eg )Nabr   xyzrB   r/   z        ab:
        - xyz
        - a      # a
        - b      # b
        - c
        - d      # d

        de:
        - 1
        - 2
        r   r   insertr   r   r   r1   r2   s      r   test_insert_0TestInsertPopList.test_insert_0t  L    DHH%	$q% Aa(F
 
 	
 
r   c                     [        U R                  5      nUS   R                  SS5        [        USS9nU[	        S5      :X  d   eg )Nr   r.   r   rB   r/   z        ab:
        - a      # a
        - b      # b
        - c
        - d      # d

        - xyz
        de:
        - 1
        - 2
        r   r   s      r   test_insert_1TestInsertPopList.test_insert_1  r   r   c                     [        U R                  5      nUS   R                  SS5        [        USS9nU[	        S5      :X  d   eg )Nr   r   r   rB   r/   z        ab:
        - a      # a
        - xyz
        - b      # b
        - c
        - d      # d

        de:
        - 1
        - 2
        r   r   s      r   test_insert_2TestInsertPopList.test_insert_2  r   r   c                     [        U R                  5      nUS   R                  S5        [        USS9n[	        U5        U[        S5      :X  d   eg )Nr   r   rB   r/   zo        ab:
        - b      # b
        - c
        - d      # d

        de:
        - 1
        - 2
        r   r   popr   printr   r   s      r   
test_pop_0TestInsertPopList.test_pop_0  P    DHH%	$AAa(aF	
 
 	
 
r   c                     [        U R                  5      nUS   R                  S5        [        USS9n[	        U5        U[        S5      :X  d   eg )Nr   r   rB   r/   zo        ab:
        - a      # a
        - c
        - d      # d

        de:
        - 1
        - 2
        r   r   s      r   
test_pop_1TestInsertPopList.test_pop_1  r   r   c                     [        U R                  5      nUS   R                  S5        [        USS9n[	        U5        U[        S5      :X  d   eg )Nr   rB   r/   zx        ab:
        - a      # a
        - b      # b
        - d      # d

        de:
        - 1
        - 2
        r   r   s      r   
test_pop_2TestInsertPopList.test_pop_2  r   r   c                     [        U R                  5      nUS   R                  S5        [        USS9n[	        U5        U[        S5      :X  d   eg )Nr      rB   r/   zn        ab:
        - a      # a
        - b      # b
        - c
        de:
        - 1
        - 2
        r   r   s      r   
test_pop_3TestInsertPopList.test_pop_3  sP    DHH%	$AAa(aF

 

 
	
 

r   r   N)r   r   r   r   __doc__propertyr   r   r   r   r   r   r   r   r   r   r   r   r   r   b  s>    <  
&
&
&
$
$
$
r   r   c                   6    \ rS rSr\S 5       rS rS rS rSr	g)TestInsertInMappingi  c                     g)Nz        first_name: Art
        occupation: Architect  # This is an occupation comment
        about: Art Vandelay is a fictional character that George invents...
        r   r   s    r   r   TestInsertInMapping.ins  s    r   c                     [        U R                  5      nUR                  SSSSS9  [        U5      n[	        U5        U[        S5      :X  d   eg )Nr   	last nameVandelaynew keycommentz        first_name: Art
        last name: Vandelay    # new key
        occupation: Architect  # This is an occupation comment
        about: Art Vandelay is a fictional character that George invents...
        r   r   r   r   r   r   r   s      r   test_insert_at_pos_1(TestInsertInMapping.test_insert_at_pos_1   S    DHH%	KY?AaF
 
 	
 
r   c                     [        U R                  5      nUR                  SSSSS9  [        U5      n[	        U5        U[        S5      :X  d   eg )Nr   r   r   r   r   z        last name: Vandelay  # new key
        first_name: Art
        occupation: Architect  # This is an occupation comment
        about: Art Vandelay is a fictional character that George invents...
        r   r   s      r   test_insert_at_pos_0(TestInsertInMapping.test_insert_at_pos_0  r   r   c                     [        U R                  5      nUR                  SSSSS9  [        U5      n[	        U5        U[        S5      :X  d   eg )Nr   r   r   r   r   z        first_name: Art
        occupation: Architect  # This is an occupation comment
        about: Art Vandelay is a fictional character that George invents...
        last name: Vandelay  # new key
        r   r   s      r   test_insert_at_pos_3(TestInsertInMapping.test_insert_at_pos_3  sS    DHH%	KY?AaF
 
 	
 
r   r   N)
r   r   r   r   r   r   r   r   r   r   r   r   r   r   r     s#     


r   r   c                   &    \ rS rSrS rS rS rSrg)TestCommentedMapMergei,  c                 ~    [        S5      nUS   S   S:X  d   eSUS   ;   d   eUS   S   S:X  d   eSUS   ;   d   eg )Nz
        x: &base
          a: 1
          b: 2
          c: 3
        y:
          <<: *base
          k: 4
          l: 5
        r   r   r   r2   )r   r   rZ   s     r   test_in_operator&TestCommentedMapMerge.test_in_operator-  sc    	
 Cy~"""d3iCy~"""d3ir   c                     [        S5      nUS   S   S:X  d   eUS   S   S:X  d   e[        R                  S:  a  [        US   5      S:X  d   eg [        US   5      S:X  d   eg )	NzH
        x: &base
          a: 1
        y:
          <<: *base
        r   r   r   r2   r      zordereddict({'a': 1})zordereddict([('a', 1)])r   sysversion_infostrr   s     r   test_issue_60#TestCommentedMapMerge.test_issue_60?  s{    
 Cy~"""Cy~"""w&tCy>%@@@@tCy>%BBBBr   c                     [        S5      nUS   S   S:X  d   eUS   S   S:X  d   e[        R                  S:  a  [        US   5      S:X  d   eg [        US   5      S:X  d   eg )	NzW
        x: &base
          a: 1
        y:
          <<: *base
          b: 2
        r   r   r   r2   r   zordereddict({'b': 2, 'a': 1})z!ordereddict([('b', 2), ('a', 1)])r   r   s     r   test_issue_60_1%TestCommentedMapMerge.test_issue_60_1O  s{    
 Cy~"""Cy~"""w&tCy>%HHHHtCy>%LLLLr   r   N)r   r   r   r   r   r   r   r   r   r   r   r   r   ,  s     $C Mr   r   c                       \ rS rSrS rS r\R                  R                  SS9S 5       r	S r
S rS	 rS
 rS rS rS rS rS rS rS rS rSrg)TestEmptyLinesia  c                 P    [        S5      n[        USS9n[        USS9nX:X  d   eg )Na          ---
        # Please add key/value pairs in alphabetical order

        aws_s3_bucket: 'mys3bucket'

        jenkins_ad_credentials:
          bind_name: 'CN=svc-AAA-BBB-T,OU=Example,DC=COM,DC=EXAMPLE,DC=Local'
          bind_pass: 'xxxxyyyy{'
        Tpreserve_quotesexplicit_startr   r   r   r   yaml_strr1   r2   s       r   test_issue_46TestEmptyLines.test_issue_46c  s5    	
 Hd;Ad3}}r   c                     [        S5        g )NzH
        a: 1x

        b: 2x


        c: 3x



        d: 4x

        r   r   s    r   test_multispace_map"TestEmptyLines.test_multispace_mapt      	
r   T)strictc                     [        S5        g )NzI

        a: 1x

        b: 2x


        c: 3x



        d: 4x

        r   r   s    r   test_multispace_map_initial*TestEmptyLines.test_multispace_map_initial  s    	
r   c                     [        S5        g )Nz:
        - a: 1y
          b: 2y

          c: 3y
        r   r   s    r   test_embedded_map TestEmptyLines.test_embedded_map  r   r   c                     [        S5        g )Nz.        - 1

        - 2

        - 3
        r   r   s    r   test_toplevel_seq TestEmptyLines.test_toplevel_seq  rc   r   c                     [        S5        g )NzN
        a:
          b:
          - 1

          - 2


          - 3
        r   r   s    r   test_embedded_seq TestEmptyLines.test_embedded_seq  r    r   c                     Sn[        USS9n[        USS9nSnUR                  5        H&  nXER                  5       S-   -  n[	        US-   5        M(     XC:X  d   eg )Nz---

a: 'x'
 
b: y
Tr   r    r   $r   r   
splitlinesrstripr   r   r   r1   r2   strippedlines         r   test_line_with_only_spaces)TestEmptyLines.test_line_with_only_spaces  sb    -Hd;Ad3'')D,,H$* * }}r   c                     Sn[        USS9n[        USS9nSnUR                  5        H&  nXER                  5       S-   -  n[	        US-   5        M(     XC:X  d   eg )Nz---  
  
a: "x"  
   
b: y  
Tr   r   r   r   r   r   r   s         r   test_some_eol_spaces#TestEmptyLines.test_some_eol_spaces  sb    7Hd;Ad3'')D,,H$* * }}r   c                     [        S5      n[        U5      n[        UR                  5        [	        USS9n[        UR                  SS5      5        X:X  d   eg )NzP        toplevel:

            # some comment
            sublevel: 300
        r.   r/   r   z$
)r   r   r   car   rY   r   s       r   test_issue_54_not_ok#TestEmptyLines.test_issue_54_not_ok  sQ    
 H%addAa(aiie$%}}r   c                 R    [        S5      n[        U5      n[        USS9nX:X  d   eg )NzO        toplevel:
            # some comment
            sublevel: 300
        r.   r/   r   r   s       r   test_issue_54_okTestEmptyLines.test_issue_54_ok  s3    
 H%Aa(}}r   c                     [        S5        g )Nzz        a:
          b:
          - c1: cat  # a1
          # my comment on catfish
          - c2: catfish  # a2
        r   r   s    r   test_issue_93TestEmptyLines.test_issue_93  rc   r   c                     [        S5        g )Nzn        a:
        - - c1: cat   # a1
          # my comment on catfish
          - c2: catfish  # a2
        r   r   s    r   test_issue_93_00TestEmptyLines.test_issue_93_00  r   r   c                     [        S5        g )Nzc        - - c1: cat   # a1
          # my comment on catfish
          - c2: catfish  # a2
        r   r   s    r   test_issue_93_01TestEmptyLines.test_issue_93_01      	
r   c                     [        S5        g )NzP        - c1: cat
        # my comment on catfish
        - c2: catfish
        r   r   s    r   test_issue_93_02TestEmptyLines.test_issue_93_02
  s    	
r   c                     [        S5        g )Nzg        a:
          b:
            c: c_val
            d:

          e:
            g: g_val
        r   r   s    r   test_issue_96TestEmptyLines.test_issue_96  s    
	
r   r   N)r   r   r   r   r   r   r   markxfailr   r   r   r   r   r  r  r	  r  r  r  r  r  r   r   r   r   r   r   a  sn    "
" [[d#
 $
$
	

		
	




r   r   c                   n    \ rS rSr\R
                  R                  \R                  S:  SS9S 5       r	Sr
g)TestUnicodeCommentsi#  )rB      zwide unicode)reasonc                     [        S5        g )Nu          name: TEST
        description: test using
        author: Harguroicha
        sql:
          command: |-
            select name from testtbl where no = :no

          ci-test:
          - :no: 04043709 # 小花
          - :no: 05161690 # 茶
          - :no: 05293147 # 〇𤋥川
          - :no: 05338777 # 〇〇啓
          - :no: 05273867 # 〇
          - :no: 05205786 # 〇𤦌
        r   r   s    r   test_issue_55!TestUnicodeComments.test_issue_55$  s    	
r   r   N)r   r   r   r   r   r  skipifr   r   r"  r   r   r   r   r  r  #  s4    [[((61.I
 J
r   r  c                   V    \ rS rSrS rS rS rS rS rS r	S r
S	 rS
 rS rS rSrg)TestEmptyValueBeforeCommentsi:  c                     [        S5        g )NzK        - a: b
          c: d
          d:  # foo
          - e: f
        r   r   s    r   test_issue_25a+TestEmptyValueBeforeComments.test_issue_25a;  r   r   c                     [        S5        g )NzK        - a: b
          c: d
          d:  # foo
            e: f
        r   r   s    r   test_issue_25a1,TestEmptyValueBeforeComments.test_issue_25a1E  r   r   c                     [        S5        g )Nz?        var1: #empty
        var2: something #notempty
        r   r   s    r   test_issue_25b+TestEmptyValueBeforeComments.test_issue_25bO  s    	
r   c                     [        S5        g )Nzi        params:
          a: 1 # comment a
          b:   # comment b
          c: 3 # comment c
        r   r   s    r   test_issue_25c+TestEmptyValueBeforeComments.test_issue_25cW  r   r   c                     [        S5        g )Nz{        params:
          a: 1 # comment a
          b:   # comment b
          # extra
          c: 3 # comment c
        r   r   s    r   test_issue_25c1,TestEmptyValueBeforeComments.test_issue_25c1a  rc   r   c                     [        S5        g )NzN        params:
          a: 1 # comment a
          b:   # comment b
        r   r   s    r   test_issue_25_00-TestEmptyValueBeforeComments.test_issue_25_00l  r  r   c                     [        S5        g )Nz        a:        # comment 1
                  #  comment 2
        - b:      #   comment 3
            c: 1  #    comment 4
        r   r   s    r   test_issue_25_01-TestEmptyValueBeforeComments.test_issue_25_01u  r   r   c                     [        S5        g )Nze        a:        # comment 1
                  #  comment 2
        - b: 2    #   comment 3
        r   r   s    r   test_issue_25_02-TestEmptyValueBeforeComments.test_issue_25_02  r  r   c                     Sn[        USSS9  g )Nze        a:        # comment 1
                  #  comment 2
          - b: 2  #   comment 3
        r.   rB   rC   r   r%   s     r   test_issue_25_03-TestEmptyValueBeforeComments.test_issue_25_03  s    
 	1Q3r   c                     [        S5        g )Nze        a:        # comment 1
                  #  comment 2
          b: 1    #   comment 3
        r   r   s    r   test_issue_25_04-TestEmptyValueBeforeComments.test_issue_25_04  r  r   c                     [        S5        g )Nz        # comment 1
        - a
        - b
        # comment 2
        - c
        - d
        # comment 3
        - [e]
        - f
        # comment 4
        - []
        r   r   s    r   test_flow_seq_within_seq5TestEmptyValueBeforeComments.test_flow_seq_within_seq  r   r   r   N)r   r   r   r   r(  r+  r.  r1  r4  r7  r:  r=  r@  rC  rF  r   r   r   r   r&  r&  :  s9    



	



4

r   r&  z%y: p
# Some comment

a: |
  x
{}b: y
c                       \ rS rSrS rSrg)TestBlockScalarWithCommentsi  c                     SS K nS HT  n[        R                  U5      nUR                  R	                  U5      nUR                  R                  U5      U:X  a  MT   e   g )Nr   )r   r   z
# Another comment
z



# abc
#xyz
rK  z# abc

#xyz
z

  # abc
  #xyz
)rp   )test_block_scalar_commented_line_templateformatrq   r   r   )r   ru   r   commented_linerZ   s        r   test_scalar_with_comments5TestBlockScalarWithComments.test_scalar_with_comments  sY     	
A GMMaPN$$44^DD$$44T:nLLL	
r   r   N)r   r   r   r   rO  r   r   r   r   rI  rI    s    Mr   rI  )r   r   r   	roundtripr   r   r   r   r	   r   r   r   r   r  r&  rL  rI  r   r   r   <module>rR     s     
 K KL/ L/^
P
 P
j2
 2
j2M 2Mj
 
D
 
.n
 n
b- )M Mr   