title: Python 3.6 project structure leads to RuntimeWarning
body: <p>I'm trying to package up my project for distribution, but I'm hitting a <code>RuntimeWarning</code> when I run the module.</p>
  
  <p>I've found a bug report on the <a href="https://bugs.python.org/issue27487" rel="noreferrer">Python mailing list</a> which indicates that the <code>RuntimeWarning</code> is new behaviour that was introduced in Python 3.5.2.</p>
  
  <p>Reading through the bug report, it appears that there is a double-import which happens, and this <code>RuntimeWarning</code> is correct in alerting the user. However, I don't see what changes that I need to make to my own project structure to avoid this issue. </p>
  
  <p>This is the first project that I have attempted to structure "correctly". I would like to have a tidy layout for when I push the code, and a project structure which can be cloned and run easily by others.</p>
  
  <p>I have based my structure mainly on <a href="http://docs.python-guide.org/en/latest/writing/structure/" rel="noreferrer">http://docs.python-guide.org/en/latest/writing/structure/</a>.</p>
  
  <p>I have added details of a minimum working example below.</p>
  
  <p>To replicate the issue, I run the main file with <code>python -m</code>:</p>
  
  <pre><code>(py36) X:\test_proj&gt;python -m proj.proj
  C:\Users\Matthew\Anaconda\envs\py36\lib\runpy.py:125: RuntimeWarning: 
  'proj.proj' found in sys.modules after import of package 'proj', but prior 
  to execution of 'proj.proj'; this may result in unpredictable behaviour
    warn(RuntimeWarning(msg))
  This is a test project.`
  </code></pre>
  
  <p>Running my tests are fine:</p>
  
  <pre><code>(py36) X:\test_proj&gt;python -m unittest tests.test_proj
  This is a test project.
  .
  ----------------------------------------------------------------------
  Ran 1 test in 0.000s
  
  OK
  </code></pre>
  
  <p>A project structure to replicate the issue is as follows:</p>
  
  <pre><code>myproject/
      proj/
          __init__.py
          proj.py
      tests/
          __init__.py
          context.py
          test_proj.py
  </code></pre>
  
  <p>In the file <code>proj/proj.py</code>:</p>
  
  <pre><code>def main():
      print('This is a test project.')
      raise ValueError
  
  if __name__ == '__main__':
      main()
  </code></pre>
  
  <p>In <code>proj/__init__.py</code>:</p>
  
  <pre><code>from .proj import main
  </code></pre>
  
  <p>In <code>tests/context.py</code>:</p>
  
  <pre><code>import os
  import sys
  sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
  import proj
  </code></pre>
  
  <p>Finally, in <code>tests/test_proj.py</code>:</p>
  
  <pre><code>import unittest
  
  from .context import proj
  
  
  class SampleTestCase(unittest.TestCase):
      """Test case for this sample project"""
      def test_raise_error(self):
          """Test that we correctly raise an error."""
          with self.assertRaises(ValueError):
              proj.main()
  
  
  if __name__ == '__main__':
      unittest.main()
  </code></pre>
  
  <p>Can anyone help me correct my project structure to avoid this double-import scenario? Any help with this would be greatly appreciated.</p>