3
d                 @   sj   d dl Z ddlmZmZmZmZ G dd dZG dd dZG dd	 d	ZG d
d dZ	G dd dZ
dS )    N   )
round_tripdedentround_trip_loadround_trip_dumpc               @   sH   e Zd Zejjdddd Zdd Zejjdddd Zd	d
 Z	dS )TestCommentFailuresT)strictc             C   s   t d d S )Nz
        # the beginning
        !!set
        # or this one?
        ? a
        # next one is B (lowercase)
        ? b  #  You see? Promised you.
        ? c
        # this is the end
        )r   )self r
   U/var/www/html/virt/lib64/python3.6/site-packages/srsly/tests/ruamel_yaml/test_fail.pytest_set_comment_before_tag   s    
z/TestCommentFailures.test_set_comment_before_tagc             C   s    d}t t|tdkstd S )Nz
        # the beginning
        !!set
        # or this one?
        ? a
        # next one is B (lowercase)
        ? b  #  You see? Promised you.
        ? c
        # this is the end
        z
        !!set
        # or this one?
        ? a
        # next one is B (lowercase)
        ? b  #  You see? Promised you.
        ? c
        # this is the end
        )r   r   r   AssertionError)r	   inpr
   r
   r   #test_set_comment_before_tag_no_fail   s    	z7TestCommentFailures.test_set_comment_before_tag_no_failc             C   s   t d d S )Nz9
        - # abc
           a: 1
           b: 2
        )r   )r	   r
   r
   r   test_comment_dash_line7   s    z*TestCommentFailures.test_comment_dash_linec             C   s$   d}t |}t|tdks td S )Nz9
        - # abc
           a: 1
           b: 2
        z7
          # abc
        - a: 1
          b: 2
        )r   r   r   r   )r	   xdatar
   r
   r   test_comment_dash_line_failA   s    z/TestCommentFailures.test_comment_dash_line_failN)
__name__
__module____qualname__pytestmarkxfailr   r   r   r   r
   r
   r
   r   r      s   
r   c               @   s2   e Zd Zejjdddd Zdd Zdd Zd	S )
TestIndentFailuresT)r   c             C   s   t d d S )Nu9  
        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
            Antarctica:
            -   too cold
        )r   )r	   r
   r
   r   test_indent_not_retainedS   s    z+TestIndentFailures.test_indent_not_retainedc             C   s$   d}t t|ddtdks td S )Nu9  
        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
            Antarctica:
            -   too cold
           )indentu?  
        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
            Antarctica:
            -   too cold
        )r   r   r   r   )r	   r   r
   r
   r    test_indent_not_retained_no_failn   s    z3TestIndentFailures.test_indent_not_retained_no_failc             C   s   d}t |dd d S )Nz(
        -   a:
            - b
        r   )r   )r   )r	   r   r
   r
   r   Xtest_indent_top_level_no_fail   s    z1TestIndentFailures.Xtest_indent_top_level_no_failN)	r   r   r   r   r   r   r   r   r   r
   r
   r
   r   r   R   s   0r   c               @   s*   e Zd Zejjdddd Zdd ZdS )TestTagFailuresT)r   c             C   s   t d d S )Nz^        !!map
        name: Anthon
        location: Germany
        language: python
        )r   )r	   r
   r
   r   test_standard_short_tag   s    z'TestTagFailures.test_standard_short_tagc             C   s$   d}d}t t|t|ks td S )Nz_
        !!map
        name: Anthon
        location: Germany
        language: python
        zQ
        name: Anthon
        location: Germany
        language: python
        )r   r   r   r   )r	   r   expr
   r
   r   test_standard_short_tag_no_fail   s    z/TestTagFailures.test_standard_short_tag_no_failN)r   r   r   r   r   r   r!   r#   r
   r
   r
   r   r       s   r    c               @   s   e Zd Zdd Zdd ZdS )TestFlowValuesc             C   s   d}t | d S )Nz        {a: bcd:efg}
        )r   )r	   r   r
   r
   r   test_flow_value_with_colon   s    z)TestFlowValues.test_flow_value_with_colonc             C   s   d}t |dd d S )Nz        {a: 'bcd:efg'}
        T)preserve_quotes)r   )r	   r   r
   r
   r   !test_flow_value_with_colon_quoted   s    z0TestFlowValues.test_flow_value_with_colon_quotedN)r   r   r   r%   r'   r
   r
   r
   r   r$      s   r$   c               @   s,   e Zd Zdd Zdd Zdd Zdd Zd	S )
TestMappingKeyc             C   s   d}t |ddd d S )Nz*        {a: 1, b: 2}: hello world
        TF)r&   Z	dump_data)r   )r	   r   r
   r
   r   test_simple_mapping_key   s    z&TestMappingKey.test_simple_mapping_keyc             C   s8   ddl m} |d	d
gdi}td}t||ks4td S )Nr   )CommentedKeyMapar   b   zhello worldz*        {a: 1, b: 2}: hello world
        )r+   r   )r,   r-   )srsly.ruamel_yaml.commentsr*   r   r   r   )r	   r*   dr"   r
   r
   r   test_set_simple_mapping_key   s
    z*TestMappingKey.test_set_simple_mapping_keyc             C   sV   ddl m} d}t|dd}|j|ddg||ddg< td
}t||ksRtd S )Nr   )r*   z*        {a: 1, b: 2}: hello world
        T)r&   r+   r   r,   r-   z*        {b: 1, a: 2}: hello world
        )r+   r   )r,   r-   )r,   r   )r+   r-   )r.   r*   r   popr   r   r   )r	   r*   r   r/   r"   r
   r
   r   "test_change_key_simple_mapping_key   s    z1TestMappingKey.test_change_key_simple_mapping_keyc             C   sH   ddl m} d}t|dd}|ddgd
i}td}t||ksDtd S )Nr   )r*   z*        {a: 1, b: 2}: hello world
        T)r&   r+   r   r,   r-   Zgoodbyez&        {a: 1, b: 2}: goodbye
        )r+   r   )r,   r-   )r.   r*   r   r   r   r   )r	   r*   r   r/   r"   r
   r
   r   $test_change_value_simple_mapping_key   s    z3TestMappingKey.test_change_value_simple_mapping_keyN)r   r   r   r)   r0   r2   r3   r
   r
   r
   r   r(      s   r(   )r   Z	roundtripr   r   r   r   r   r   r    r$   r(   r
   r
   r
   r   <module>	   s   DT