示例#1
0
文件: tests.py 项目: jqb/os.path2
def test_unlink():
    target = os.path.join("xxx", "symlink")

    os.symlink(os.path.realpath(file_1_path), target)

    assert path(target).exists
    path(target).unlink()
    assert not path(target).exists
示例#2
0
文件: tests.py 项目: jqb/os.path2
def test_base_methods():

    path_1 = path("/tmp/file with spaces").replace(" ", "-")
    assert isinstance(path_1, path)
    assert path_1 == "/tmp/file-with-spaces"

    path_2 = path("smallfile").upper()
    assert isinstance(path_2, path)
    assert path_2 == "SMALLFILE"

    path_3 = path("/tmp/file.txt")[:5]
    assert isinstance(path_3, path)
    assert path_3 == "/tmp/"
示例#3
0
文件: tests.py 项目: jqb/os.path2
def test_ls_dirs():
    dir_content = path(root).ls_dirs()

    names_only = [a.basename for a in dir_content]

    assert len(dir_content) == len(dir_list)
    assert set(dir_list).issubset(names_only)
    assert not set(file_list).issubset(names_only)
示例#4
0
文件: tests.py 项目: jqb/os.path2
def test__div__():
    joined_path = path(root) / path(file_1)
    assert joined_path.exists

    joined_path = path(root) / file_1
    assert joined_path.exists

    joined_path = path(root) / path(file_1) / path("xxx")
    assert not joined_path.exists

    joined_path = path(root) / path(file_1) / "xxx"
    assert not joined_path.exists
示例#5
0
文件: tests.py 项目: jqb/os.path2
def test_rm():
    path(file_1_path).rm()
    assert not os.path.exists(file_1_path)

    path(dir_1_path).rm()
    assert not os.path.exists(dir_1_path)

    file_location = os.path.join(dir_2_path, "xxx")
    open(file_location, "w")

    with pytest.raises(OSError):
        path(dir_2_path).rm()
    assert os.path.exists(dir_2_path)

    path(dir_2_path).rm(r=True)
    assert not os.path.exists(dir_2_path)
示例#6
0
文件: tests.py 项目: jqb/os.path2
def test_ln_hard():
    symlink = path(file_1_path).ln(os.path.join("xxx", "symlink"), s=False)

    assert symlink.exists
    assert not symlink.is_link()
示例#7
0
文件: tests.py 项目: jqb/os.path2
def test_ln_s():
    symlink = path(file_1_path).ln(os.path.join("xxx", "symlink"))

    assert symlink.exists
    assert symlink.is_link()
示例#8
0
文件: tests.py 项目: jqb/os.path2
def test_is_file():
    assert path(file_1_path).is_file()
    assert path(file_2_path).is_file()

    assert not path(dir_1_path).is_file()
    assert not path(dir_2_path).is_file()
示例#9
0
文件: tests.py 项目: jqb/os.path2
def test_absolute():
    assert os.path.abspath(file_1_path) == path(file_1_path).absolute
示例#10
0
文件: tests.py 项目: jqb/os.path2
def test_exists():
    assert path(dir_1_path).exists
    assert path(file_1_path).exists
示例#11
0
文件: tests.py 项目: jqb/os.path2
def test_split():
    path_1 = path("/tmp/directory/file")
    assert all([isinstance(p, path) for p in path_1.split()])
示例#12
0
文件: tests.py 项目: jqb/os.path2
def test_iter():
    dir_content = path(root)
    assert len([e for e in dir_content]) == len(dir_list + file_list)
示例#13
0
文件: tests.py 项目: jqb/os.path2
def test_touch():
    path_string = os.path.join(root, "test")
    path(path_string).touch()

    assert os.path.exists(path_string)
    assert os.path.isfile(path_string)
示例#14
0
文件: tests.py 项目: jqb/os.path2
def test_cp():
    file_copy = path(file_1_path).cp(os.path.join(root, "file_copy"))
    assert os.path.exists(file_copy)

    dir_copy = path(dir_1_path).cp(os.path.join(root, "dir_copy"))
    assert os.path.exists(dir_copy)
示例#15
0
文件: tests.py 项目: jqb/os.path2
def test_mkdir():
    path_string = os.path.join(root, "test")
    path(path_string).mkdir()

    assert os.path.exists(path_string)
    assert os.path.isdir(path_string)
示例#16
0
文件: tests.py 项目: jqb/os.path2
def test_path():
    assert path(root, file_1).exists
    assert not path(root, file_1, "xxxss").exists
示例#17
0
文件: setup.py 项目: jqb/os.path2
        errno = subprocess.call([sys.executable, "runtests.py", "tests.py"])
        raise SystemExit(errno)


setup(
    name="os.path2",
    version=path2.__version__,
    data_files=[(get_python_lib(), [pth_file])],
    packages=find_packages(),
    author="Sebastian Pawluś",
    author_email="*****@*****.**",
    url="https://github.com/xando/osome",
    description="The os.path module replacement, with simple API.",
    keywords="os path ",
    license=path2.path("LICENSE").open("r").read(),
    long_description=path2.path("README.rst").open("r").read(),
    include_package_data=True,
    zip_safe=False,
    platforms=["any"],
    classifiers=[
        "Development Status :: 4 - Beta",
        "Intended Audience :: Developers",
        "License :: OSI Approved :: BSD License",
        "Operating System :: OS Independent",
        "Programming Language :: Python",
        "Programming Language :: Python :: 2.6",
        "Programming Language :: Python :: 2.7",
        "Programming Language :: Python :: 3.3",
        "Programming Language :: Python :: Implementation :: PyPy",
    ],
示例#18
0
文件: tests.py 项目: jqb/os.path2
def test_mkdir_p():
    path_string = os.path.join(root, "level1", "level2")
    path(path_string).mkdir(p=True)

    assert os.path.exists(path_string)
    assert os.path.isdir(path_string)