Is directory name `test` treated in a special manner?

If I have a directory named mypackage, it is recognized as a package without me having to do anything (not even mark it as a source directory or create a file):

If however I simply change the directory's name to test, it is no longer recognized as a package (import does not work). Why is that? Is the name test treated differently? That does not seem to be documented anywhere that I could see.
(Adding a file does get the example to work, but that still does not explain the different behavior based on the name.)


Hello there,
Could you please check where Jump to definition leads (CTRL/ Command + Click) if you click on test in from test.testing_util import foo?


Ah, there is a built-in Python package testI was not aware of that's being picked up before my own definition of test. And, of course, the built-in package does not contain a testing_util module, so this generates the error.

Thanks for helping!


Please sign in to leave a comment.