ubelt icon indicating copy to clipboard operation
ubelt copied to clipboard

pathlib is missing in requirements/tests.txt

Open yurivict opened this issue 3 years ago • 5 comments

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 avatar Aug 10 '22 05:08 yurivict

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

yurivict avatar Aug 10 '22 05:08 yurivict

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.

Erotemic avatar Aug 10 '22 05:08 Erotemic

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

yurivict avatar Aug 10 '22 05:08 yurivict

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.

Erotemic avatar Aug 10 '22 05:08 Erotemic

$ python3.9 -c "import pathlib; print(pathlib.__file__)"
/usr/local/lib/python3.9/pathlib.py

yurivict avatar Aug 10 '22 05:08 yurivict