Beispiel #1
0
def test_relative_of_cwd_with_three_dots():
    """Calling jay with `...` should be expanded to cwd/.../.../"""
    mkdir('dir1/dir2')
    two_level_deep_dir = os.path.join(TEST_DIR, 'dir1', 'dir2')
    with mock.patch.object(os, 'getcwd', return_value=two_level_deep_dir):
        result = relative_of_cwd('...')
    eq_(result, TEST_DIR)
Beispiel #2
0
def test_relative_of_cwd_with_one_dot_and_one_dotted_child():
    """Calling jay with `. with a .dir should prioratize cwd over
       the dotted dirname"""
    mkdir('.dir')
    with mock.patch.object(os, 'getcwd', return_value=TEST_DIR):
        result = relative_of_cwd('.')
    eq_(result, TEST_DIR)
Beispiel #3
0
def test_relative_of_cwd_with_three_dots_and_three_dotted_child():
    """Calling jay with `... with a ...dir should prioratize ../../cwd over
       the dotted dirname"""
    mkdir('dir/dir2/...dir')
    cwd = os.path.join(TEST_DIR, 'dir', 'dir2')  # im in TEST_DIR/dir/dir2/
    with mock.patch.object(os, 'getcwd', return_value=cwd):
        result = relative_of_cwd('...')
    eq_(result, TEST_DIR)
Beispiel #4
0
def test_relative_of_unexistant_cwd_with_one_dot():
    """Calling jay with `.` on a non existant dir should yield None"""
    mkdir('')
    fake_dir = os.path.join(TEST_DIR, 'fake_dir')
    assert not os.path.isdir(fake_dir)

    with mock.patch.object(os, 'getcwd', return_value=fake_dir):
        result = relative_of_cwd('.')
    assert result is None
Beispiel #5
0
def test_nonexistant_relative_of_cwd_with_three_dots():
    """Calling jay with `...` should None if cwd/.../.../ doesn't exists"""
    mkdir('')  # just rootdir
    fake_dir = os.path.join(TEST_DIR, 'fake_dir')
    assert not os.path.isdir(fake_dir)

    two_level_deep_dir = os.path.join(fake_dir, 'dir1', 'dir2')
    with mock.patch.object(os, 'getcwd', return_value=two_level_deep_dir):
        result = relative_of_cwd('...')
    assert result is None
Beispiel #6
0
def test_relative_of_cwd_with_one_dot():
    """Calling jay with `.` should be expanded to cwd"""
    mkdir('')
    with mock.patch.object(os, 'getcwd', return_value=TEST_DIR):
        result = relative_of_cwd('.')
    eq_(TEST_DIR, result)