Detect examples based on directory, not file name.

This avoids misidentifying tests such as "test_foo_example.py"
as examples. Relates salilab/imp#792.