https://pantsbuild.org/ logo
#general
Title
# general
f

fresh-continent-76371

03/19/2023, 12:08 AM
A strange migration tip; situation. 1. have an existing sizeable python repo with embedded /test/folders - hundreds of tests (makes sense, tests are local to the code) - large++ code base 2. some test folders have modules, (helpers, utils) but are missing
__init__.py
files goal: locate all directories under test folders, that don't have
__init__.py
files, but do have
*.py
files, this is not fool-proof but it did locate the > 30 folders I had to investigate ; to remove the "pants can't infer" (output of a test, was mostly written to a
output/
subfolder (.gitignore'd) ) • read as, find directories that are "test" and have
.py
files, but no
__init__.py
files
Copy code
❯ find . -type d -wholename '*/test*' -not -name __pycache__ -not -wholename '*/test/*output*' -not -wholename '*/.venv*' -exec find {} -maxdepth 1 -type f -name '*.py' -not -name 'test_*' -quit \; -not -exec test -e "{}/__init__.py"  \;  -print
💪 1