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