Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.8.4: pytest is failing #73

Open
kloczek opened this issue Mar 28, 2023 · 1 comment
Open

0.8.4: pytest is failing #73

kloczek opened this issue Mar 28, 2023 · 1 comment

Comments

@kloczek
Copy link

kloczek commented Mar 28, 2023

I'm packaging your module as an rpm package so I'm using the typical PEP517 based build, install and test cycle used on building packages from non-root account.

  • python3 -sBm build -w --no-isolation
  • because I'm calling build with --no-isolation I'm using during all processes only locally installed modules
  • install .whl file in </install/prefix>
  • run pytest with $PYTHONPATH pointing to sitearch and sitelib inside </install/prefix>
  • build is performed in env which is cut off from access to the public network (pytest is executed with -m "not network")

Here is pytest output:

+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-ypy-websocket-0.8.4-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-ypy-websocket-0.8.4-2.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra -m 'not network'
==================================================================================== test session starts ====================================================================================
platform linux -- Python 3.8.16, pytest-7.2.2, pluggy-1.0.0
rootdir: /home/tkloczko/rpmbuild/BUILD/ypy-websocket-0.8.4, configfile: pyproject.toml
plugins: asyncio-0.21.0
asyncio: mode=auto
collected 7 items

tests/test_ypy_yjs.py FF                                                                                                                                                              [ 28%]
tests/test_ystore.py .....                                                                                                                                                            [100%]

========================================================================================= FAILURES ==========================================================================================
_____________________________________________________________________________________ test_ypy_yjs_0[0] _____________________________________________________________________________________

yws_server = <ypy_websocket.websocket_server.WebsocketServer object at 0x7f6816f66880>, yjs_client = <subprocess.Popen object at 0x7f6816f66fa0>

    @pytest.mark.asyncio
    @pytest.mark.parametrize("yjs_client", "0", indirect=True)
    async def test_ypy_yjs_0(yws_server, yjs_client):
        ydoc = Y.YDoc()
        ytest = YTest(ydoc)
        websocket = await connect("ws://127.0.0.1:1234/my-roomname")
        WebsocketProvider(ydoc, websocket)
        ymap = ydoc.get_map("map")
        # set a value in "in"
        for v_in in range(10):
            with ydoc.begin_transaction() as t:
                ymap.set(t, "in", float(v_in))
            ytest.run_clock()
>           await ytest.clock_run()

tests/test_ypy_yjs.py:51:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_ypy_yjs.py:34: in clock_run
    await asyncio.wait_for(change.wait(), timeout=self.timeout)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

fut = <Task cancelled name='Task-16' coro=<Event.wait() done, defined at /usr/lib64/python3.8/asyncio/locks.py:296>>, timeout = 1.0

    async def wait_for(fut, timeout, *, loop=None):
        """Wait for the single Future or coroutine to complete, with timeout.

        Coroutine will be wrapped in Task.

        Returns result of the Future or coroutine.  When a timeout occurs,
        it cancels the task and raises TimeoutError.  To avoid the task
        cancellation, wrap it in shield().

        If the wait is cancelled, the task is also cancelled.

        This function is a coroutine.
        """
        if loop is None:
            loop = events.get_running_loop()
        else:
            warnings.warn("The loop argument is deprecated since Python 3.8, "
                          "and scheduled for removal in Python 3.10.",
                          DeprecationWarning, stacklevel=2)

        if timeout is None:
            return await fut

        if timeout <= 0:
            fut = ensure_future(fut, loop=loop)

            if fut.done():
                return fut.result()

            await _cancel_and_wait(fut, loop=loop)
            try:
                fut.result()
            except exceptions.CancelledError as exc:
                raise exceptions.TimeoutError() from exc
            else:
                raise exceptions.TimeoutError()

        waiter = loop.create_future()
        timeout_handle = loop.call_later(timeout, _release_waiter, waiter)
        cb = functools.partial(_release_waiter, waiter)

        fut = ensure_future(fut, loop=loop)
        fut.add_done_callback(cb)

        try:
            # wait until the future completes or the timeout
            try:
                await waiter
            except exceptions.CancelledError:
                if fut.done():
                    return fut.result()
                else:
                    fut.remove_done_callback(cb)
                    # We must ensure that the task is not running
                    # after wait_for() returns.
                    # See https://bugs.python.org/issue32751
                    await _cancel_and_wait(fut, loop=loop)
                    raise

            if fut.done():
                return fut.result()
            else:
                fut.remove_done_callback(cb)
                # We must ensure that the task is not running
                # after wait_for() returns.
                # See https://bugs.python.org/issue32751
                await _cancel_and_wait(fut, loop=loop)
>               raise exceptions.TimeoutError()
E               asyncio.exceptions.TimeoutError

/usr/lib64/python3.8/asyncio/tasks.py:501: TimeoutError
----------------------------------------------------------------------------------- Captured stderr call ------------------------------------------------------------------------------------
node:internal/modules/cjs/loader:1093
  throw err;
  ^

Error: Cannot find module 'yjs'
Require stack:
- /home/tkloczko/rpmbuild/BUILD/ypy-websocket-0.8.4/tests/yjs_client_0.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1090:15)
    at Module._load (node:internal/modules/cjs/loader:934:27)
    at Module.require (node:internal/modules/cjs/loader:1157:19)
    at require (node:internal/modules/helpers:119:18)
    at Object.<anonymous> (/home/tkloczko/rpmbuild/BUILD/ypy-websocket-0.8.4/tests/yjs_client_0.js:1:11)
    at Module._compile (node:internal/modules/cjs/loader:1275:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1329:10)
    at Module.load (node:internal/modules/cjs/loader:1133:32)
    at Module._load (node:internal/modules/cjs/loader:972:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/tkloczko/rpmbuild/BUILD/ypy-websocket-0.8.4/tests/yjs_client_0.js'
  ]
}

Node.js v19.8.1
_____________________________________________________________________________________ test_ypy_yjs_1[1] _____________________________________________________________________________________

yws_server = <ypy_websocket.websocket_server.WebsocketServer object at 0x7f6816f37040>, yjs_client = <subprocess.Popen object at 0x7f6816ee88b0>

    @pytest.mark.asyncio
    @pytest.mark.parametrize("yjs_client", "1", indirect=True)
    async def test_ypy_yjs_1(yws_server, yjs_client):
        # wait for the JS client to connect
        tt, dt = 0, 0.1
        while True:
            await asyncio.sleep(dt)
            if "/my-roomname" in yws_server.rooms:
                break
            tt += dt
            if tt >= 1:
>               raise RuntimeError("Timeout waiting for client to connect")
E               RuntimeError: Timeout waiting for client to connect

tests/test_ypy_yjs.py:67: RuntimeError
----------------------------------------------------------------------------------- Captured stderr call ------------------------------------------------------------------------------------
node:internal/modules/cjs/loader:1093
  throw err;
  ^

Error: Cannot find module 'yjs'
Require stack:
- /home/tkloczko/rpmbuild/BUILD/ypy-websocket-0.8.4/tests/yjs_client_1.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1090:15)
    at Module._load (node:internal/modules/cjs/loader:934:27)
    at Module.require (node:internal/modules/cjs/loader:1157:19)
    at require (node:internal/modules/helpers:119:18)
    at Object.<anonymous> (/home/tkloczko/rpmbuild/BUILD/ypy-websocket-0.8.4/tests/yjs_client_1.js:1:11)
    at Module._compile (node:internal/modules/cjs/loader:1275:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1329:10)
    at Module.load (node:internal/modules/cjs/loader:1133:32)
    at Module._load (node:internal/modules/cjs/loader:972:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/tkloczko/rpmbuild/BUILD/ypy-websocket-0.8.4/tests/yjs_client_1.js'
  ]
}

Node.js v19.8.1
================================================================================== short test summary info ==================================================================================
FAILED tests/test_ypy_yjs.py::test_ypy_yjs_0[0] - asyncio.exceptions.TimeoutError
FAILED tests/test_ypy_yjs.py::test_ypy_yjs_1[1] - RuntimeError: Timeout waiting for client to connect
================================================================================ 2 failed, 5 passed in 2.33s ================================================================================

Here is list of installed modules in build env

Package           Version
----------------- --------------
aiofiles          23.1.0
attrs             22.2.0
build             0.10.0
distro            1.8.0
editables         0.3
exceptiongroup    1.0.0
gpg               1.18.0-unknown
hatchling         1.13.0
iniconfig         2.0.0
libcomps          0.1.19
packaging         23.0
pathspec          0.11.0
pip               23.0.1
pluggy            1.0.0
pyproject_hooks   1.0.0
pytest            7.2.2
pytest-asyncio    0.21.0
python-dateutil   2.8.2
rpm               4.17.0
six               1.16.0
tomli             2.0.1
typing_extensions 4.5.0
websockets        10.4
wheel             0.38.4
y-py              0.6.1
@davidbrochart
Copy link
Collaborator

Tests need some packages to be installed with node.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants