Esempio 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)
Esempio 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)
Esempio 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
Esempio 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
Esempio 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
Esempio 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
Esempio 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
Esempio 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
Esempio 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)
Esempio 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')
Esempio 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")
Esempio 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")
Esempio 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")
Esempio 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')
Esempio 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")
Esempio 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
Esempio 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"))
Esempio n. 18
0
def test_dir_does_not_exist():
    with pytest.raises(OSError):
        with open_run_dir("/not/a/real/dir"):
            pass
Esempio n. 19
0
def test_dir_does_not_exist():
    with pytest.raises(OSError):
        with open_run_dir("/not/a/real/dir"):
            pass
Esempio 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"))
Esempio 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
Esempio 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)
Esempio 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')))
Esempio n. 24
0
def test_dir_does_not_exist():
    with assert_raises(OSError):
        with open_run_dir('/not/a/real/dir'):
            pass