def test_python3_stretch_venv_not_deleted_in_stretch(self, tmpdir, caplog):
     venv_path = str(tmpdir)
     python_lib_path = os.path.join(venv_path, 'lib/python3.5')
     os.makedirs(python_lib_path)
     with mock.patch('bootstrap.is_tails', return_value=True):
         with mock.patch('subprocess.check_output', return_value="stretch"):
             bootstrap.clean_up_tails3_venv(venv_path)
             assert os.path.exists(venv_path)
 def test_python3_buster_venv_not_deleted_in_buster(self, tmpdir, caplog):
     venv_path = str(tmpdir)
     python_lib_path = os.path.join(venv_path, 'lib/python3.7')
     os.makedirs(python_lib_path)
     with mock.patch('bootstrap.is_tails', return_value=True):
         with mock.patch('subprocess.check_output', return_value="buster"):
             bootstrap.clean_up_tails3_venv(venv_path)
             assert ('Tails 3 Python 3 virtualenv detected'
                     not in caplog.text)
             assert os.path.exists(venv_path)
 def test_venv_cleanup_subprocess_exception(self, tmpdir, caplog):
     venv_path = str(tmpdir)
     python_lib_path = os.path.join(venv_path, 'lib/python3.5')
     os.makedirs(python_lib_path)
     with mock.patch('bootstrap.is_tails', return_value=True):
         with mock.patch('subprocess.check_output',
                         side_effect=subprocess.CalledProcessError(1,
                                                                   ':o')):
             bootstrap.clean_up_tails3_venv(venv_path)
             assert os.path.exists(venv_path)