acoustic-library-86413
09/27/2023, 8:33 AMmy-package/
tests/
integration/
unit/
some_shared_module.py
my_package/
This leads to ambiguous imports in a monorepo setting, e.g. from tests.some_shared_module import some_function
. It's not something we use often, as most things are better suited in conftest.py
, but often enough that Pants is complaining very loudly. From what I can tell I can either remove the ambiguity by specifying dependencies explicitly, or I can move all tests to a top-level tests
folder with sub-folders for each project. Really just keen to hear how others have dealt with this and if there are other methods I haven't thought of.late-advantage-75311
09/27/2023, 8:45 AMsome_shared_module
really shared? If so, you could consolidate it in in one place and have it imported from there. I.e. you don't have to have a top-level tests
folder but it sounds like you do want a top-level test_utils
folder.late-advantage-75311
09/27/2023, 8:46 AMfrom test_utils.some_shared_module import some_function
broad-processor-92400
09/27/2023, 8:47 AMtests
as you mention, Pants itself does ..._test.py
files adjacent to the real code (i.e. foo.py
is a sibling of foo_test.py
)acoustic-library-86413
09/27/2023, 10:04 AMbroad-processor-92400
09/27/2023, 10:54 AMfrom . import some_shared_module
? Maybe another option to toss on the pile to considerhappy-kitchen-89482
09/27/2023, 9:21 PMhappy-kitchen-89482
09/27/2023, 9:22 PMhappy-kitchen-89482
09/27/2023, 9:22 PMhappy-kitchen-89482
09/27/2023, 9:23 PMhappy-kitchen-89482
09/27/2023, 9:23 PMhappy-kitchen-89482
09/27/2023, 9:23 PM