Exemplo n.º 1
0
def test_nested_dirs():
    init_dir = os.getcwd()
    with open_run_dir('/'):
        assert_equal(os.getcwd(), '/')
        with open_run_dir('/bin'):
            assert_equal(os.getcwd(), '/bin')
        assert_equal(os.getcwd(), '/')
    assert_equal(os.getcwd(), init_dir)
Exemplo n.º 2
0
def test_nested_relative_dirs():
    init_dir = os.getcwd()
    with open_run_dir('/usr/bin'):
        assert_equal(os.getcwd(), '/usr/bin')
        with open_run_dir('..'):
            assert_equal(os.getcwd(), '/usr')
        assert_equal(os.getcwd(), '/usr/bin')
    assert_equal(os.getcwd(), init_dir)
Exemplo n.º 3
0
def test_nested_relative_dirs():
    init_dir = os.getcwd()
    with open_run_dir("/usr/bin"):
        assert os.getcwd() == os.path.normpath("/usr/bin")
        with open_run_dir(".."):
            assert os.getcwd() == os.path.normpath("/usr")
        assert os.getcwd() == os.path.normpath("/usr/bin")
    assert os.getcwd() == init_dir
Exemplo n.º 4
0
def test_nested_dirs():
    init_dir = os.getcwd()
    with open_run_dir("/"):
        assert os.getcwd() == os.path.normpath("/")
        with open_run_dir("/bin"):
            assert os.getcwd() == os.path.normpath("/bin")
        assert os.getcwd() == os.path.normpath("/")
    assert os.getcwd() == init_dir
Exemplo n.º 5
0
def test_negative_dir():
    init_dir = os.getcwd()
    with open_run_dir("/"):
        assert os.getcwd() == "/"
        with open_run_dir(".."):
            assert os.getcwd() == "/"
        assert os.getcwd() == "/"
    assert os.getcwd() == init_dir
Exemplo n.º 6
0
def test_negative_dir():
    init_dir = os.getcwd()
    with open_run_dir("/"):
        assert os.getcwd() == "/"
        with open_run_dir(".."):
            assert os.getcwd() == "/"
        assert os.getcwd() == "/"
    assert os.getcwd() == init_dir
Exemplo n.º 7
0
def test_nested_relative_dirs():
    init_dir = os.getcwd()
    with open_run_dir("/usr/bin"):
        assert os.getcwd() == os.path.normpath("/usr/bin")
        with open_run_dir(".."):
            assert os.getcwd() == os.path.normpath("/usr")
        assert os.getcwd() == os.path.normpath("/usr/bin")
    assert os.getcwd() == init_dir
Exemplo n.º 8
0
def test_nested_dirs():
    init_dir = os.getcwd()
    with open_run_dir("/"):
        assert os.getcwd() == os.path.normpath("/")
        with open_run_dir("/bin"):
            assert os.getcwd() == os.path.normpath("/bin")
        assert os.getcwd() == os.path.normpath("/")
    assert os.getcwd() == init_dir
Exemplo n.º 9
0
def test_negative_dir():
    init_dir = os.getcwd()
    with open_run_dir('/'):
        assert_equal(os.getcwd(), '/')
        with open_run_dir('..'):
            assert_equal(os.getcwd(), '/')
        assert_equal(os.getcwd(), '/')
    assert_equal(os.getcwd(), init_dir)
Exemplo n.º 10
0
def test_create_missing_dir():
    init_dir = os.getcwd()
    with open_run_dir('./not/a/dir', create=True):
        assert_equal(os.getcwd(), os.path.join(init_dir, 'not/a/dir'))
    assert_equal(os.getcwd(), init_dir)
    assert_true(os.path.isdir(os.path.join(init_dir, 'not/a/dir')))
    shutil.rmtree('./not')
Exemplo n.º 11
0
def test_create_missing_dir():
    init_dir = os.getcwd()
    with open_run_dir("./not/a/dir", create=True):
        assert os.getcwd() == os.path.normpath(os.path.join(init_dir, "not/a/dir"))
    assert os.getcwd() == init_dir
    assert os.path.isdir(os.path.normpath(os.path.join(init_dir, "not/a/dir")))
    shutil.rmtree("./not")
Exemplo n.º 12
0
def test_create_missing_dir():
    init_dir = os.getcwd()
    with open_run_dir("./not/a/dir", create=True):
        assert os.getcwd() == os.path.normpath(
            os.path.join(init_dir, "not/a/dir"))
    assert os.getcwd() == init_dir
    assert os.path.isdir(os.path.normpath(os.path.join(init_dir, "not/a/dir")))
    shutil.rmtree("./not")
Exemplo n.º 13
0
def test_do_not_gobble_exception():
    init_dir = os.getcwd()
    try:
        with open_run_dir("/usr"):
            assert os.getcwd() == "/usr"
            raise ValueError()
    except ValueError:
        assert os.getcwd() == init_dir
    else:
        raise AssertionError("statement should not be reached")
Exemplo n.º 14
0
def test_do_not_gobble_exception():
    init_dir = os.getcwd()
    try:
        with open_run_dir('/usr'):
            assert_equal(os.getcwd(), '/usr')
            raise ValueError()
    except ValueError:
        assert_equal(os.getcwd(), init_dir)
    else:
        raise AssertionError('statement should not be reached')
Exemplo n.º 15
0
def test_do_not_gobble_exception():
    init_dir = os.getcwd()
    try:
        with open_run_dir("/usr"):
            assert os.getcwd() == "/usr"
            raise ValueError()
    except ValueError:
        assert os.getcwd() == init_dir
    else:
        raise AssertionError("statement should not be reached")
Exemplo n.º 16
0
def test_relative_dir():
    init_dir = os.getcwd()
    with open_run_dir(".."):
        assert os.getcwd() == os.path.abspath(os.path.join(init_dir, ".."))
    assert os.getcwd() == init_dir
Exemplo n.º 17
0
def test_missing_dir():
    init_dir = os.getcwd()
    with pytest.raises(OSError):
        with open_run_dir("./not/a/dir"):
            pass
    assert not os.path.isdir(os.path.join(init_dir, "not/a/dir"))
Exemplo n.º 18
0
def test_dir_does_not_exist():
    with pytest.raises(OSError):
        with open_run_dir("/not/a/real/dir"):
            pass
Exemplo n.º 19
0
def test_dir_does_not_exist():
    with pytest.raises(OSError):
        with open_run_dir("/not/a/real/dir"):
            pass
Exemplo n.º 20
0
def test_missing_dir():
    init_dir = os.getcwd()
    with pytest.raises(OSError):
        with open_run_dir("./not/a/dir"):
            pass
    assert not os.path.isdir(os.path.join(init_dir, "not/a/dir"))
Exemplo n.º 21
0
def test_relative_dir():
    init_dir = os.getcwd()
    with open_run_dir(".."):
        assert os.getcwd() == os.path.abspath(os.path.join(init_dir, ".."))
    assert os.getcwd() == init_dir
Exemplo n.º 22
0
def test_relative_dir():
    init_dir = os.getcwd()
    with open_run_dir('..'):
        assert_equal(os.getcwd(), os.path.abspath(os.path.join(init_dir,
                                                               '..')))
    assert_equal(os.getcwd(), init_dir)
Exemplo n.º 23
0
def test_missing_dir():
    init_dir = os.getcwd()
    with assert_raises(OSError):
        with open_run_dir('./not/a/dir'):
            pass
    assert_false(os.path.isdir(os.path.join(init_dir, 'not/a/dir')))
Exemplo n.º 24
0
def test_dir_does_not_exist():
    with assert_raises(OSError):
        with open_run_dir('/not/a/real/dir'):
            pass