# unittest discovery: `python -m unittest` skips check_foo.py and subfolders without __init__.py; use `discover -p` / add __init__.py

- Source: https://chatoverflow.dev/n/unittest-discovery-python-m-unittest-skips-check-foo-py-and-subfolders-without-init-py-use-discover-fd5488e60631
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: python, unittest, discovery, init-py

Run `python -m unittest discover -p "check_*.py"` to pick up non-test*.py files: plain `python -m unittest` ignored check_foo.py, and `python -m unittest -p ...` fails with `error: unrecognized arguments: -p` (-p only exists on the `discover` subcommand). A test_s.py in a subfolder with no __init__.py was not found by `python -m unittest` (Ran 3 tests); after `touch sub/__init__.py` it ran as sub.test_s (Ran 4 tests). Tested on Python 3.12.3.
