Exemplo n.º 1
0
def test_base_methods():

    path_1 = path("/tmp/file with spaces").replace(" ", "-")
    path_2 = path("smallfile").upper()

    assert isinstance(path_1, path)
    assert path_1 == '/tmp/file-with-spaces'

    assert isinstance(path_2, path)
    assert path_2 == 'SMALLFILE'
Exemplo n.º 2
0
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
Exemplo n.º 3
0
def test_ls_dirs():
    dir_content = path(root).ls_dirs()

    assert len(dir_content) == len(dir_list)

    assert set(dir_list).issubset(dir_content)
    assert not set(file_list).issubset(dir_content)
Exemplo n.º 4
0
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
Exemplo n.º 5
0
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)
Exemplo n.º 6
0
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()
Exemplo n.º 7
0
def test_ln_s():
    symlink = path(file_1_path).ln(os.path.join('xxx', 'symlink'))

    assert symlink.exists
    assert symlink.is_link()
Exemplo n.º 8
0
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()
Exemplo n.º 9
0
def test_absolute():
    assert os.path.abspath(file_1_path) == path(file_1_path).absolute
Exemplo n.º 10
0
def test_exists():
    assert path(dir_1_path).exists
    assert path(file_1_path).exists
Exemplo n.º 11
0
def test_iter():
    dir_content = path(root)
    assert len([e for e in dir_content]) == len(dir_list + file_list)
Exemplo n.º 12
0
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)
Exemplo n.º 13
0
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)
Exemplo n.º 14
0
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)
Exemplo n.º 15
0
def test_path():
    assert path(root, file_1).exists
    assert not path(root, file_1, 'xxxss').exists
Exemplo n.º 16
0
# -*- coding: utf-8 -*-
from setuptools import setup, find_packages
from shelltools import path

description = "The bucket of python shell helpers, no dependencies, simple API."

project = path(__file__).dir()

long_description = (project / 'README.rst').open("r").read()
version = (project / 'VERSION').open("r").read()
license = (project / 'LICENSE').open("r").read()


setup(name='shelltools',
      version=version,
      packages=find_packages(),
      author='Sebastian Pawluś',
      author_email='*****@*****.**',
      url='https://github.com/xando/python-shelltools',
      description=description,
      keywords="shell tools shell path ",
      license=license,
      long_description=long_description,
      include_package_data=True,
      platforms=['any'],
      classifiers=[
          'Development Status :: 4 - Beta',
          'Intended Audience :: Developers',
          'Natural Language :: English',
          'License :: OSI Approved :: BSD License',
          'Operating System :: OS Independent',
Exemplo n.º 17
0
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)