
    *j                       d Z ddlmZ ddlZddlmc mZ ddl	Z	ddl
mZ ddlZddlmZ ddlmZ  ee          j        j        dz  ZdZej        d	             Zej        d
             Zej        j        d             Zej        j        d             Zej        j        d             Zej        j        d             Zej        j        d             ZdS )uD   Tests for compiler/stages/style.py — all offline via FakeProvider.    )annotationsN)Path)	run_style)FakeProviderfixturesa  ---
source_id: test-src
title: Test Source
rights: public-domain
fetch_type: gutenberg
---

# Test Source

You have power over your mind, not outside events. Realize this, and you will find strength.

The impediment to action advances action. What stands in the way becomes the way.

Very little is needed to make a happy life; it is all within yourself in your way of thinking.

Confine yourself to the present and you will live a peaceful life.

The soul becomes dyed with the color of its thoughts.
c                r    | dz  }|                                  |dz                      t                     |S )Ncorpustest-src.md)mkdir
write_text	CORPUS_MD)tmp_pathds     B/Users/jameslopez/projects/MentorCore/tests/compiler/test_style.py
corpus_dirr   %   s7    8AGGIII""9---H    c                 :    t          j        t          dz            S )Nstyle_extraction.jsonl)r   
from_jsonlFIXTURES r   r   style_providerr   -   s    "8.F#FGGGr   c                  K   |dz  }t          d| dz  i||           d {V \  }}|j        } |            }|sddt          j                    v st	          j        |          rt	          j        |          ndt	          j        |          t	          j        |          dz  }t          t	          j        |                    d x}}|j        } |            }|sddt          j                    v st	          j        |          rt	          j        |          ndt	          j        |          t	          j        |          dz  }t          t	          j        |                    d x}}d S )Nstyletest-srcr
   Aassert %(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.exists
}()
}profile_pathpy0py2py4exemplars_path)	r   exists@py_builtinslocals
@pytest_ar_should_repr_global_name	_safereprAssertionError_format_explanation)	r   r   r   	style_dirr   r"   @py_assert1@py_assert3@py_format5s	            r   test_run_style_creates_profiler/   5   s     7"I)2	Z-/0* * $ $ $ $ $ $ L.
                 <     <                               "  """"""""""""""">""""">"""""" """"""""""""""""""""""""""r   c                  K   |dz  }t          d| dz  i||           d {V \  }}|                                }d}||v }|st          j        d|fd||f          t          j        |          dt          j                    v st          j        |          rt          j        |          nddz  }	d	d
|	iz  }
t          t          j	        |
                    d x}}d S )Nr   r   r
   #inz%(py1)s in %(py3)scontentpy1py3assert %(py5)spy5)
r   	read_textr&   _call_reprcomparer(   r$   r%   r'   r)   r*   )r   r   r   r+   r   _r5   @py_assert0@py_assert2@py_format4@py_format6s              r   #test_run_style_profile_has_sectionsrB   A   s.     7"I%	Z-/0       OL!
 $$&&G3'>3'3''r   c                P  K   |dz  }t          d| dz  i||           d {V \  }}d |                                                                D             }t          |          }d}||k    }	|	st	          j        d|	fd||f          dt          j                    v st	          j        t                    rt	          j	        t                    ndd	t          j                    v st	          j        |          rt	          j	        |          nd	t	          j	        |          t	          j	        |          d
z  }
dd|
iz  }t          t	          j        |                    d x}x}	}|D ]}t          j        |          }d}||v }|st	          j        d|fd||f          t	          j	        |          dt          j                    v st	          j        |          rt	          j	        |          nddz  }dd|iz  }t          t	          j        |                    d x}}|d         }t          |t                    }	|	sddt          j                    v st	          j        t                    rt	          j	        t                    ndt	          j	        |          dt          j                    v st	          j        t                    rt	          j	        t                    ndt	          j	        |	          dz  }t          t	          j        |                    d x}}	d S )Nr   r   r
   c                :    g | ]}|                                 |S r   )strip).0lns     r   
<listcomp>z<test_run_style_exemplars_are_valid_jsonl.<locals>.<listcomp>X   s%    PPPBRXXZZPRPPPr   r   )>)z/%(py3)s
{%(py3)s = %(py0)s(%(py1)s)
} > %(py6)slenlines)r   r7   r8   py6zassert %(py8)spy8textr2   r4   recordr6   r9   r:   z5assert %(py5)s
{%(py5)s = %(py0)s(%(py2)s, %(py3)s)
}
isinstancestr)r   r    r8   r:   )r   r;   
splitlinesrJ   r&   r<   r$   r%   r'   r(   r)   r*   jsonloadsrP   rQ   )r   r   r   r+   r=   r"   rK   r?   @py_assert5@py_assert4@py_format7@py_format9linerO   r>   r@   rA   r,   s                     r   (test_run_style_exemplars_are_valid_jsonlrZ   N   sr      7"I'	Z-/0       A~
 QP.2244??AAPPPEu:::>:33uu: / /D!!vvv ..z.#...............z.....z..................#.....#.........................../ /r   c                V  K   |dz  }t          j        t          dz            }t          d| dz  i||           d{V \  }}|                                }g }d}||v }	|	}
|	s#d}|j        } |            }||v }|}
|sd}||v }|}
|
st          j        d	|	fd
||f          t          j        |          dt          j
                    v st          j        |          rt          j        |          nddz  }dd|iz  }|                    |           |	s>t          j        d	|fd||f          t          j        |          dt          j
                    v st          j        |          rt          j        |          ndt          j        |          t          j        |          dz  }dd|iz  }|                    |           |st          j        d	|fd||f          t          j        |          dt          j
                    v st          j        |          rt          j        |          nddz  }dd|iz  }|                    |           t          j        |d          i z  }dd|iz  }t          t          j        |                    dx}
x}x}x}	x}x}x}x}x}}dS )u2   Recorded golden response — deterministic replay.r   r   r   r
   NStoicausterez# Toner2   )z%(py3)s in %(py5)sr5   )r8   r:   z%(py7)spy7)zJ%(py10)s in %(py16)s
{%(py16)s = %(py14)s
{%(py14)s = %(py12)s.lower
}()
})py10py12py14py16z%(py18)spy18)z%(py21)s in %(py23)s)py21py23z%(py25)spy25   zassert %(py28)spy28)r   r   r   r   r;   lowerr&   r<   r(   r$   r%   r'   append_format_boolopr)   r*   )r   r   r+   providerr   r=   r5   r,   r?   rV   r>   @py_assert9@py_assert13@py_assert15@py_assert11@py_assert20@py_assert22rA   @py_format8@py_format17@py_format19@py_format24@py_format26@py_format27@py_format29s                            r   test_run_style_golden_outputrz   `   sh      7"I&x2J'JKKH%	Z-/0       OL!
 $$&&GTT7T7gTTTTTTgmTmmooTo!=TTTTTTWATTTTTTTTTTTT7gTTTTT7TTTTTTTTTTTgTTTTTgTTTTTTTTTTTTTTTTTTTTTTTTTTTTToTTTTTTTTTTTTTTTTgTTTTTgTTTTTTmTTTToTTTTTTTTTTTTTTTTTTTTTTTTTTTWTTTTTTTTTTTTTTTTWTTTTTWTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTr   c                  K   | dz  }t          j        t          dz            }t          i ||           d {V \  }}|j        } |            }|sddt          j                    v st          j        |          rt          j	        |          ndt          j	        |          t          j	        |          dz  }t          t          j        |                    d x}}|j        } |            }|sddt          j                    v st          j        |          rt          j	        |          ndt          j	        |          t          j	        |          dz  }t          t          j        |                    d x}}d S )Nr   r   r   r   r   r"   )r   r   r   r   r#   r$   r%   r&   r'   r(   r)   r*   )r   r+   rl   r   r"   r,   r-   r.   s           r   test_run_style_empty_corpusr|   n   s     7"I&x2J'JKKH)22y()K)K#K#K#K#K#K#K L.                <     <                               "  """"""""""""""">""""">"""""" """"""""""""""""""""""""""r   )__doc__
__future__r   builtinsr$   _pytest.assertion.rewrite	assertionrewriter&   rS   pathlibr   pytestcompiler.stages.styler   runtime.providers.faker   __file__parentr   r   fixturer   r   markasyncior/   rB   rZ   rz   r|   r   r   r   <module>r      s   J J " " " " " "                      + + + + + + / / / / / /4>> '*4	,    H H H # # # 	 	 	 / / /" 
U 
U 
U # # # # #r   