Erotemic / ubelt

A Python utility library with a stdlib like feel and extra batteries. Paths, Progress, Dicts, Downloads, Caching, Hashing: ubelt makes it easy!
Apache License 2.0
719 stars 43 forks source link

pathlib is missing in requirements/tests.txt #128

Closed yurivict closed 1 year ago

yurivict commented 2 years ago

Describe the bug Some tests expect pathlib:

tests/test_path.py::test_pathlib SKIPPED (pathlib is not installed) [ 83%]

but it isn't in requirements/tests.txt

yurivict commented 2 years ago

pathlib is an old version, now the current version is pathlib2.

Erotemic commented 2 years ago

The pathlib module is a standard library module. It's always installed in Python 3.4+ Recent versions of ubelt only support Python 3.6+, but older releases do support other older Python versions.

yurivict commented 2 years ago

I use python-39 and the test depending on pathlib is skipped because it isn't available.

Erotemic commented 2 years ago

Something is wrong. The pathlib module should always be available on 3.9.

What is the result of:

python3 -c "import pathlib; print(pathlib.__file__)"

?

Oh, I think I see the problem now. The test_pathlib test itself is bad.

def test_pathlib():
    try:
        import pathlib
        base = pathlib.Path(ub.ensure_app_cache_dir('ubelt'))
        dpath = base.joinpath('test_pathlib_mkdir')

        # ensuredir
        ub.delete(dpath)
        assert not dpath.exists()
        got = ub.ensuredir(dpath)
        assert got.exists()

        # shrinkuser
        assert ub.shrinkuser(base) == '~/.cache/ubelt'

        assert ub.augpath(base, prefix='foo') == '/home/joncrall/.cache/fooubelt'

        ub.expandpath(base)

    except Exception:
        import pytest
        pytest.skip('pathlib is not installed')

I hardcoded my machine name into it, and the exception catches anything. Changing that line to str(ub.Path('~/.cache/fooubelt').expand()) should work. This is a test from when ubelt still supported 2.7, which is why the try/except is there. It should just be removed now.

yurivict commented 2 years ago
$ python3.9 -c "import pathlib; print(pathlib.__file__)"
/usr/local/lib/python3.9/pathlib.py