zauberzeug / nicegui

Create web-based user interfaces with Python. The nice way.
https://nicegui.io
MIT License
8.89k stars 538 forks source link

Missing testing/plugin.py file? #3431

Closed lanetaylor25 closed 1 month ago

lanetaylor25 commented 1 month ago

Description

Hi - I am attempting to write unit tests for my nicegui application. When trying to set the pytest plugin 'nicegui.testing.plugins', I get ImportError: Error importing plugin "nicegui.testing.plugin": No module named 'nicegui.testing.plugin'.

When I look at the installed nicegui package in my poetry virtual environment, I see that the file 'nicegui/testing/plugin.py' does not actually exist. I'm running 1.4.30.

What am I missing?

lanetaylor25 commented 1 month ago

Conftest.py:

pytest_plugins = ['nicegui.testing.plugin']

Test file:

import pytest
from nicegui.testing import Screen
from typing import Generator
from source.equipment import Equipment

@pytest.fixture
def screen(screen: Screen) -> Generator[Screen, None, None]:
    Equipment().build()
    yield screen

def test_cards(screen: Screen):
    screen.should_contain('Item')
lanetaylor25 commented 1 month ago

I see this behavior on Windows 10 and Windows 11, and I've tried nicegui versions 1.4.9-1.4.30. All seem to give me this problem. I'm hoping I'm just missing something really simple, but so far I can't figure out what.

python-and-fiction commented 1 month ago

in https://github.com/zauberzeug/nicegui/blob/v1.4.30/tests/conftest.py ,it is this:

# pylint: disable=wildcard-import,unused-wildcard-import
from nicegui.testing.conftest import *  # noqa: F403

main branch will be nicegui 2.0, if you try 1.4.30,you shouldn't use main branch.

rodja commented 1 month ago

We will shortly release the new testing infrastructure in 1.4.31 because there are no breaking changes. Until then you either install the main branch with pip or use the old style described by @python-and-fiction.

lanetaylor25 commented 1 month ago

Thank you! This worked for me as expected. Could you please let me know when nicegui 2.0 and 1.4.31 are expected to release? Or where I can find information about upcoming releases myself?

I really appreciate the help.

rodja commented 1 month ago

1.4.31 is going to be released in the next days. And 2.0 hopefully still in August. We plan the releases in milestones: https://github.com/zauberzeug/nicegui/milestones, but often without a release date. It's ready when it's ready 😉