title: How to run automated tests with pytest for a package with classes?
body: <p>I am new to using pytest, and running automated tests in general, and I want to know best practice for running automated tests in a python package that contains classes. I have a package, <code>p</code>, that contains classes <code>A</code>, <code>B</code>, and <code>C</code>. I have one file, <code>test_p</code> which contains four test functions. In order to test these functions, I need to import <code>A</code>, <code>B</code>, and <code>C</code>. The way I'm doing this currently is by having an <code>__init__.py</code> file in my <code>p</code> repository, which contains the following lines:</p>
  
  <pre><code>from p.A import A
  from p.B import B
  from p.C import C
  </code></pre>
  
  <p>Then, within the directory containing the <code>p</code> directory, I launch python and run the commands:</p>
  
  <pre><code>from p import *
  import pytest
  </code></pre>
  
  <p>then, I navigate inside <code>p</code>, and within python run:</p>
  
  <pre><code>pytest.main([`test_p`])
  </code></pre>
  
  <p>This procedure for testing my package does not seem optimal to me, and I'm sure there's a better way to do it. Ideally, I would like to be able to just run a script in the OS terminal and/or within the python terminal that runs <code>test_p</code>, and have this script exist inside the <code>p</code> directory. The issue is that I can't import <code>A</code>, <code>B</code>, and <code>C</code> from within <code>p</code> itself. Is there a way to run a script that would run <code>test_p</code> (or just run <code>test_p</code> directly) without having to navigate between directories?</p>