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

Bug: CLI auto-discovery test: AssertionError: assert 'app:app' == 'app.any_name:any_name' #2379

Open
1 of 4 tasks
peterschutt opened this issue Sep 28, 2023 · 3 comments
Open
1 of 4 tasks
Labels
CLI This is related to our CLI tests-issue This is an issue specifically due to tests

Comments

@peterschutt
Copy link
Contributor

peterschutt commented Sep 28, 2023

Description

I couldn't see an existing issue for this, but have noticed it a few times recently.

_____________________________________________________________________ test_env_from_env_autodiscover_from_files[app_factory_future_annot-app_module_random] _____________________________________________________________________
[gw4] linux -- Python 3.8.17 /home/peter/.cache/pypoetry/virtualenvs/litestar-_gLDtdjb-py3.8/bin/python

path = 'any_name.py', app_file_content = '\nfrom __future__ import annotations\n\nfrom litestar import Litestar\n\ndef any_name() -> Litestar:\n    return Litestar([])\n\n\ndef func():\n    return False\n'
app_file_app_name = 'any_name', create_app_file = <function create_app_file.<locals>._create_app_file at 0x7fd477aa2940>

    @pytest.mark.parametrize(
        "path",
        [
            pytest.param("app.py", id="app_file"),
            pytest.param("application.py", id="application_file"),
            pytest.param("app/main.py", id="app_module"),
            pytest.param("app/any_name.py", id="app_module_random"),
            pytest.param("application/another_random_name.py", id="application_module_random"),
        ],
    )
    def test_env_from_env_autodiscover_from_files(
        path: str, app_file_content: str, app_file_app_name: str, create_app_file: CreateAppFileFixture
    ) -> None:
        directory = None
        if "/" in path:
            directory, path = path.split("/", 1)
    
        tmp_file_path = create_app_file(file=path, directory=directory, content=app_file_content)
        env = LitestarEnv.from_env(None)
    
        dotted_path = _path_to_dotted_path(tmp_file_path.relative_to(Path.cwd()))
    
        assert isinstance(env.app, Litestar)
>       assert env.app_path == f"{dotted_path}:{app_file_app_name}"
E       AssertionError: assert 'app:app' == 'app.any_name:any_name'
E         - app.any_name:any_name
E         + app:app

/home/peter/PycharmProjects/litestar/tests/unit/test_cli/test_env_resolution.py:78: AssertionError
----------------------------------------------------------------------------------------------------- Captured stdout call ------------------------------------------------------------------------------------------------------
Using Litestar app from app:app
==================================================================================================== short test summary info ====================================================================================================
FAILED tests/unit/test_cli/test_env_resolution.py::test_env_from_env_autodiscover_from_files[app_factory_future_annot-app_module_random] - AssertionError: assert 'app:app' == 'app.any_name:any_name'
==================================================================================== 1 failed, 3223 passed, 42 skipped, 2 xfailed in 40.50s =====================================================================================

URL to code causing the issue

No response

MCVE

# Your MCVE code here

Steps to reproduce

1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

Screenshots

"![SCREENSHOT_DESCRIPTION](SCREENSHOT_LINK.png)"

Logs

No response

Litestar Version

main

Platform

  • Linux
  • Mac
  • Windows
  • Other (Please specify in the description above)

Funding

  • If you would like to see an issue prioritized, make a pledge towards it!
  • We receive the pledge once the issue is completed & verified
Fund with Polar
@peterschutt peterschutt added Bug 🐛 This is something that is not working as expected Triage Required 🏥 This requires triage labels Sep 28, 2023
@peterschutt
Copy link
Contributor Author

Interesting thing is, I'm consistently getting one or two of these errors running make test locally which is using 8 cores.

If I run the tests single threaded pytest then no errors.

I'm working on the branch for this PR: #2378 - and at the time of writing, the last CI run, which uses 2 cores had no errors.

@peterschutt
Copy link
Contributor Author

And for good measure - the last run on my local machine on 8 cores had no errors (there was errors 4-5 times in a row which lead me to believe there might be some correlation with the changes I'm making in that PR branch, but maybe not).

@provinzkraut
Copy link
Member

Can you check if pinning the tests in this file to one worker with pytest.mark.xdist_group helps?

@peterschutt peterschutt added Bug 🐛 This is something that is not working as expected and removed Bug 🐛 This is something that is not working as expected Triage Required 🏥 This requires triage labels Sep 30, 2023
@provinzkraut provinzkraut added tests-issue This is an issue specifically due to tests and removed Bug 🐛 This is something that is not working as expected labels Sep 30, 2023
@JacobCoffee JacobCoffee added the CLI This is related to our CLI label Dec 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLI This is related to our CLI tests-issue This is an issue specifically due to tests
Projects
Status: Backlog
Development

No branches or pull requests

3 participants