def test_uninstall(sp_dir, conda_pth, request): ''' `conda develop --uninstall pkg_path` invokes uninstall() to remove path from conda.pth - this is a unit test for uninstall It also includes a cleanup function that deletes the conda.pth file :param str sp_dir: path to site-packages directory returned by fixture :param str conda_pth: path to conda.pth returned by fixture ''' # first write data in conda.pth if it doesn't yet exist # if all tests are invoked, then conda.pth exists if not exists(conda_pth): for pth in _path_in_dev_mode: write_to_conda_pth(sp_dir, pth) for to_rm, exp_num_pths in _torm_and_num_after_uninstall: # here's where the testing begins _uninstall(sp_dir, to_rm) assert exists(conda_pth) with open(conda_pth, 'r') as f: lines = f.readlines() assert to_rm + '\n' not in lines assert len(lines) == exp_num_pths
def test_write_to_conda_pth(sp_dir, conda_pth): ''' `conda develop pkg_path` invokes write_to_conda_pth() to write/append to conda.pth - this is a basic unit test for write_to_conda_pth :param str sp_dir: path to site-packages directory returned by fixture :param str conda_pth: path to conda.pth returned by fixture ''' assert not exists(conda_pth) for pth, exp_num_pths in _toadd_and_num_after_install: write_to_conda_pth(sp_dir, pth) assert exists(conda_pth) # write to path twice but ensure it only gets written to fine once write_to_conda_pth(sp_dir, pth) with open(conda_pth, 'r') as f: lines = f.readlines() assert (pth + '\n') in lines assert len(lines) == exp_num_pths