title: beyond top level package error in relative import
body: <p>It seems there are already quite some questions here about relative import in python 3, but after going through many of them I still didn't find the answer for my issue. 
  so here is the question. </p>
  
  <p>I have a package shown below</p>
  
  <pre><code>package/
     __init__.py
     A/
        __init__.py
        foo.py
     test_A/
        __init__.py
        test.py
  </code></pre>
  
  <p>and I have a single line in test.py:</p>
  
  <pre><code>from ..A import foo
  </code></pre>
  
  <p>now, I am in the folder of <code>package</code>, and I run </p>
  
  <pre><code>python -m test_A.test
  </code></pre>
  
  <p>I got message</p>
  
  <pre><code>"ValueError: attempted relative import beyond top-level package"
  </code></pre>
  
  <p>but if I am in the parent folder of <code>package</code>, e.g., I run:</p>
  
  <pre><code>cd ..
  python -m package.test_A.test
  </code></pre>
  
  <p>everything is fine. </p>
  
  <p><strong>Now my question is:</strong> 
  when I am in the folder of <code>package</code>, and I run the module inside the test_A sub-package as <code>test_A.test</code>, based on my understanding, <code>..A</code> goes up only one level, which is still within the <code>package</code> folder, why it gives message saying <code>beyond top-level package</code>. What is exactly the reason that causes this error message?</p>