title: Why does Python's unittest give "ImportError: Import by filename is not supported." in WSL bash?
body: <p>On Windows, I have a Python code base with some unit tests (based on <code>unittest</code>) in sub-folders.</p>
  
  <p>I use the Windows Command Prompt to change to the folder and run all tests using <code>python -m unittest subfolder/tests.py</code>. The tests in the file are then detected and run.</p>
  
  <p>When I try to do the same in the Windows Subsystem for Linux bash shell, I get the following error with stack trace:</p>
  
  <pre><code>Traceback (most recent call last):
    File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
      "__main__", fname, loader, pkg_name)
    File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
      exec code in run_globals
    File "/usr/lib/python2.7/unittest/__main__.py", line 12, in &lt;module&gt;
      main(module=None)
    File "/usr/lib/python2.7/unittest/main.py", line 94, in __init__
      self.parseArgs(argv)
    File "/usr/lib/python2.7/unittest/main.py", line 149, in parseArgs
      self.createTests()
    File "/usr/lib/python2.7/unittest/main.py", line 158, in createTests
      self.module)
    File "/usr/lib/python2.7/unittest/loader.py", line 130, in loadTestsFromNames
      suites = [self.loadTestsFromName(name, module) for name in names]
    File "/usr/lib/python2.7/unittest/loader.py", line 91, in loadTestsFromName
      module = __import__('.'.join(parts_copy))
  ImportError: Import by filename is not supported.
  </code></pre>
  
  <p><strong>Why does this error occur in WSL bash but not in cmd? How can I fix this to work in both?</strong></p>
  
  <p>PS - Here is an example of a <code>tests.py</code> as referred to above:</p>
  
  <pre><code>import unittest
  from target import target
  
  class tests(unittest.TestCase):
  
    def test_pi(self):
        expected = 3.1415926
        actual = truncate(target.pi(), 7)
        self.assertEqual(actual, expected)
  
    def truncate(num, digits):
        return int(num * 10**digits) / 10**digits
  
  if __name__ == '__main__':
      unittest.main()
  </code></pre>