Skip to content

pytest collection overwrites testcases in monorepo like structure #13997

@indiVar0508

Description

@indiVar0508

Hi

I have a monorepo, where I have following directory structure

Project/
      repo/
             pkg1/
                     src/
                     tests/
                            …
                            __init__.py
                           test_main.py
             pkg2/
                     src/
                     tests/
                            …
                            __init__.py
                           test_main.py

I also have other mini packages which don’t follow src layout, I have added —import-mode=importlib in root pyproject for addopts
But what I am seeing is test_main.py for pkg2 gets overwritten for pkg1 I.e. in test_main.py for pkg1 I have 3 test cases and in test_main.py for pkg2 I have 8 tests cases, but when I see in logs of pytest I see

…
pkg2/tests/test_main . . . # should have eight

From my understand and my guess is this is happening because when pytest resolves unique path for each it might be picking tests.test_main for both.

I tried verbose run and I can see the test name from pkg1 in path of pkg2

I needed some help guidance / help to point me in right direction to properly setup this for my usecase

Thanks !

Originally posted by @indiVar0508 in #13749

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions