Example #1
0
def test_destroy_ioerror():
  with temporary_dir() as d:
    ds = DirectorySandbox(d)
    ds.create()

    with mock.patch('shutil.rmtree') as shutil_rmtree:
      shutil_rmtree.side_effect = IOError('What even are you doing?')
      with pytest.raises(DirectorySandbox.DeletionError):
        ds.destroy()
Example #2
0
def test_destroy_ioerror():
    with temporary_dir() as d:
        real_path = os.path.join(d, "sandbox")
        ds = DirectorySandbox(real_path)
        ds.create()

        with mock.patch("shutil.rmtree") as shutil_rmtree:
            shutil_rmtree.side_effect = IOError("What even are you doing?")
            with pytest.raises(DirectorySandbox.DeletionError):
                ds.destroy()
Example #3
0
def test_destroy_ioerror():
    with temporary_dir() as d:
        real_path = os.path.join(d, 'sandbox')
        ds = DirectorySandbox(real_path)
        ds.create()

        with mock.patch('shutil.rmtree') as shutil_rmtree:
            shutil_rmtree.side_effect = IOError('What even are you doing?')
            with pytest.raises(DirectorySandbox.DeletionError):
                ds.destroy()
def test_directory_sandbox():
  with temporary_dir() as d:
    ds1 = DirectorySandbox(os.path.join(d, 'task1'))
    ds2 = DirectorySandbox(os.path.join(d, 'task2'))
    ds1.create()
    ds2.create()
    assert os.path.exists(ds1.root)
    assert os.path.exists(ds2.root)
    ds1.destroy()
    assert not os.path.exists(ds1.root)
    assert os.path.exists(ds2.root)
    ds2.destroy()
    assert not os.path.exists(ds2.root)
Example #5
0
def test_directory_sandbox():
    with temporary_dir() as d:
        ds1 = DirectorySandbox(os.path.join(d, 'task1'))
        ds2 = DirectorySandbox(os.path.join(d, 'task2'))
        ds1.create()
        ds2.create()
        assert os.path.exists(ds1.root)
        assert os.path.exists(ds2.root)
        ds1.destroy()
        assert not os.path.exists(ds1.root)
        assert os.path.exists(ds2.root)
        ds2.destroy()
        assert not os.path.exists(ds2.root)