title: How do I import files in Python?
body: <p>I'm trying to use <code>pytest</code> to check a function—here is my code: </p>
  
  <pre><code># src/return_self.py
  def return_self(n):
      return n
  
  
  # tests/return_self_test.py
  import pytest
  
  def test_1():
      value = return_self(1)
      assert value == 1
  </code></pre>
  
  <p>How do I require in my <code>src</code> file so that I can test it with <code>pytest</code>? I have tried a few things:</p>
  
  <pre><code>1. import return_self
  2. from src.return_self import *
  3. import sys
     sys.path.append('../src')
  4. import imp
     return_self = imp.load_source('return_self', '/source/return_self.py')
  </code></pre>
  
  <p>I have also tried them with and without <code>__init__.py</code> files in the root and <code>src</code> directories. But each time, I get some variation on the error <code>E   ModuleNotFoundError: No module named 'return_self'</code>. How can I require in my file?</p>