예제 #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)
예제 #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)
예제 #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
예제 #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
예제 #5
0
파일: test_run_dir.py 프로젝트: csdms/pymt
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
예제 #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
예제 #7
0
파일: test_run_dir.py 프로젝트: csdms/pymt
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
예제 #8
0
파일: test_run_dir.py 프로젝트: csdms/pymt
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
예제 #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)
예제 #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')
예제 #11
0
파일: test_run_dir.py 프로젝트: csdms/pymt
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")
예제 #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")
예제 #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")
예제 #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')
예제 #15
0
파일: test_run_dir.py 프로젝트: csdms/pymt
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")
예제 #16
0
파일: test_run_dir.py 프로젝트: csdms/pymt
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
예제 #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"))
예제 #18
0
파일: test_run_dir.py 프로젝트: csdms/pymt
def test_dir_does_not_exist():
    with pytest.raises(OSError):
        with open_run_dir("/not/a/real/dir"):
            pass
예제 #19
0
def test_dir_does_not_exist():
    with pytest.raises(OSError):
        with open_run_dir("/not/a/real/dir"):
            pass
예제 #20
0
파일: test_run_dir.py 프로젝트: csdms/pymt
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"))
예제 #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
예제 #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)
예제 #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')))
예제 #24
0
def test_dir_does_not_exist():
    with assert_raises(OSError):
        with open_run_dir('/not/a/real/dir'):
            pass