jupyter / jupyter_core

Core Jupyter functionality
https://jupyter-core.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
194 stars 180 forks source link

save path tests from symlink confusion, fixes #231 #375

Open ivanov opened 8 months ago

ivanov commented 8 months ago

following this comment in #231

@mtelka could you please try this out and report back if this fixes the last set of failures you see on your OpenIndiana rig? Thank you!

mtelka commented 8 months ago

I tested jupyter_core 5.5.0 with 5f24503 applied and the failure is very similar to the one reported in https://github.com/jupyter/jupyter_core/issues/231#issuecomment-1738547230.

Please note that /usr/share/jupyter and /usr/local/share/jupyter does not point to the same target so pure realpath() cannot solve the issue. On default OpenIndiana install the /usr/local does not exist. On my test machine it is a symlink to /opt/local as documented here so with 5f24503 the failure of test_jupyter_path_user_site is this now:

_________________________ test_jupyter_path_user_site __________________________

    def test_jupyter_path_user_site():
        with patch.object(site, "ENABLE_USER_SITE", True):
            path = jupyter_path()

            # deduplicated expected values
            values = list(
                dict.fromkeys(
                    [   
                        jupyter_data_dir(),
                        os.path.join(site.getuserbase(), "share", "jupyter"),
                        paths.ENV_JUPYTER_PATH[0],
                    ]
                )
            )
            for p, v in zip(path, values):
>               assert realpath(p) == realpath(v)
E               AssertionError: assert '/opt/local/share/jupyter' == '/usr/share/jupyter'
E                 - /usr/share/jupyter
E                 + /opt/local/share/jupyter

p          = '/usr/local/share/jupyter'
path       = ['/home/marcel/.local/share/jupyter', '/usr/local/share/jupyter', '/usr/share/jupyter']
v          = '/usr/share/jupyter'
values     = ['/home/marcel/.local/share/jupyter', '/usr/share/jupyter']

tests/test_paths.py:300: AssertionError

The other two tests fails with the exactly same error output as before.

ivanov commented 8 months ago

Ah, ok, I wrongly assumed that it was a symlink resolution issue. What do you think is the path forward ?

mtelka commented 8 months ago

What about to find the root cause first? :-)

ivanov commented 7 months ago

What about to find the root cause first? :-)

I fully support that, but lack a system that reproduces this error, which is why I ask for help.

mtelka commented 7 months ago

What about to find the root cause first? :-)

I fully support that, but lack a system that reproduces this error, which is why I ask for help.

What kind of help do you need? I know nothing about jupiter_core, but I can run any suggested patches. I can even root cause a bit, but I need more info about jupiter_core.

For example with test_jupyter_path_user_site: what do you think is wrong? The jupyter_core itself, or the test itself with wrong expectation?