IDLE will have the `sample` module already loaded and as it passes its `sys.modules` to the subprocess that runs `test.py` it is found.
You will probably find that it will not work outside Idle anywhere, eg at the command line, if `test.py` is run from `Desktop`. Thats not a Geany thing, its how Python works.