
    c                         d dl Z d dlZd dlZd dlZd dlZd dlmZ  G d dej                        Z G d dej                        Z	y)    N)basec                   4    e Zd ZdZd Zd Zd Zd Zd Zd Z	y)	TestCore)pbr_test_cmdpbr_test_cmd_with_classc                 h   | j                   D ]  }d|d| j                  }| j                  ||       t        j                  j                  | j                  |      }t        |d      j                         }| j                  d|       | j                  |      \  }}}| j                  d|        y )NzInstalling z script to rpkg_resourcesPBR)
	cmd_namestemp_dirassertInospathjoinopenreadassertNotIn_run_cmd)	selfinstall_stdoutcmd_nameinstall_txtcmd_filename
script_txtstdout_return_codes	            5/usr/lib/python3/dist-packages/pbr/tests/test_core.pycheck_script_installzTestCore.check_script_install7   s     	)H:B:>--IKMM+~677<<x@LlC0557J_j9%)]]<%@"FA{MM%(	)    c                 ^    | j                  d       | j                  d      \  }}}|dk(  sJ y)zsetup.py --keywords.

        Test that the `./setup.py --keywords` command returns the correct
        value without balking.
        egg_infoz
--keywordsz packaging, distutils, setuptoolsN)	run_setup)r   r   r   s      r   test_setup_py_keywordszTestCore.test_setup_py_keywordsE   s3     	z"~~l31;;;;r!   c                 R    | j                  d      \  }}}| j                  d|       y )Nbuild_sphinxr   )r$   assertEqualr   r   r   r   s       r   test_setup_py_build_sphinxz#TestCore.test_setup_py_build_sphinxP   s'    !%!?;K(r!   c                    | j                  dd      \  }}}	 t        j                  t        j                  j	                  dd            d   }t        j                  |      }|j                         D cg c]%  }dj	                  |j                  d      dd	       ' }}| j                  d
|       y	# t
        $ r J d       w xY wc c}w )z.Test that the extra files are correctly added.sdist--formats=gztardist*.tar.gzr   zsource dist not found/   Nzextra-file.txt)r$   globr   r   r   
IndexErrortarfiler   getnamessplitr   )r   r   r   r   tf_pathtfpnamess           r   test_sdist_extra_fileszTestCore.test_sdist_extra_filesT   s     "&9J!K;	2iiVZ @A!DG \\'"57[[]C!''#,qr*+CC&.  	21115	2 Ds   6B4 5*C4Cc                     t         j                  dk(  r| j                  d       | j                  dd| j                  z        \  }}}| j                  t        j                  dd             | j                  |       y)z8Test that we install a non-pkg-resources console script.ntWindows support is passthroughinstall_scripts--install-dir=%s
PYTHONPATH.N)	r   nameskipTestr$   r   
useFixturefixturesEnvironmentVariabler    r)   s       r   test_console_script_installz$TestCore.test_console_script_installd   so     77d?MM:;!%1DMMA"C; 	((s;	= 	!!&)r!   c                 `   t         j                  dk  r| j                  d       t        j                  dk(  r| j                  d       | j                  t        j                  dd| j                  z               | j                  dd| j                  z        \  }}}| j                  |       y	)
z8Test that we develop a non-pkg-resources console script.)   r   zRFails with recent virtualenv due to https://github.com/pypa/virtualenv/issues/1638r=   r>   rA   z.:%sdevelopr@   N)sysversion_inforD   r   rC   rE   rF   rG   r   r$   r    r)   s       r   test_console_script_developz$TestCore.test_console_script_developr   s     f$MMA
 77d?MM:;((ft}}46	7 "&)DMM9";; 	!!&)r!   N)
__name__
__module____qualname__r   r    r%   r*   r;   rH   rN    r!   r   r   r   3   s%    ;I)	<)/ **r!   r   c                   $     e Zd Z fdZd Z xZS )TestGitSDistc                     t         t        |           | j                  dd      \  }}}|r| j	                  d       | j                  dd      \  }}}| j                  dd      \  }}}| j                  dd      \  }}}y )Ngit)initzgit not installed)addrB   )commitz-mzTurn this into a git repor,   r-   )superrT   setUpr   rD   r$   )r   r   r   r   	__class__s       r   r[   zTestGitSDist.setUp   s    lD')!%ui!@;MM-.!%ul!C;!%@"B; "&9J!K;r!   c                 D   t        j                   t        j                  j                  dd            d   }t	        j
                  |      }|j                         D cg c]%  }dj                  |j                  d      dd       ' }}| j                  d|       yc c}w )z7Test that extra files found in git are correctly added.r.   r/   r   r0   r1   Nzgit-extra-file.txt)	r2   r   r   r   r4   r   r5   r6   r   )r   r7   r8   r9   r:   s        r   test_sdist_git_extra_filesz'TestGitSDist.test_sdist_git_extra_files   sz     ))BGGLL<=a@\\'"57[[]C!''#,qr*+CC*E2 Ds   *B)rO   rP   rQ   r[   r^   __classcell__)r\   s   @r   rT   rT      s    L3r!   rT   )
r2   r   rL   r4   rF   	pbr.testsr   BaseTestCaser   rT   rR   r!   r   <module>rb      sA   R  	 
   R*t   R*j34$$ 3r!   