Here is my folder structure:
.
├── mod
│   └── a.py
└── tests
    └── test_a.py
2 directories, 2 files
tests/test_a.py simply looks like this:
import unittest
from mod import a
class ATestCase(unittest.TestCase):
    def test_a(self):
        print(a.a)
if __name__ == "__main__":
    unittest.main()
When I do unittest, surely everything is fine:
$ python -m unittest tests/test_a.py 
1
.
----------------------------------------------------------------------
Ran 1 test in 0.000s
OK
However, when I simply run tests/test_a.py as a python script, error happens:
$ python tests/test_a.py 
Traceback (most recent call last):
  File "tests/test_a.py", line 2, in <module>
    from mod import a
ImportError: No module named 'mod'
My question is why, using unittest, mod becomes importable?