pytest collecting 0 items
<p>I have a socket program - 2 scripts, server and client. On server side I have many functions. I want to test these functions. I am new to python. Found something called pytest. So for all functions on my server side I did something like this. </p>

<pre><code>def fun(a):
   // fn definition
   return b
def test_fun():
   assert fun(test_case) == "expected value"
</code></pre>

<p>I named this server script as test_server.py and imported pytest. I have imported pytest on client side also and renamed the script to test_client.py Then when I run using</p>

<blockquote>
  <p>py.test test_server.py</p>
</blockquote>

<p>and then </p>

<blockquote>
  <p>py.test test_client.py</p>
</blockquote>

<p>On server side it says collecting 0 items, and that's it. It is not collecting any. Any idea where I am going wrong. BTW I tried with simple python codes. There pytest is working properly. Is it that pytest doesn't work with socket programming or am I doing any mistake ? Also there is no mistake in codes without using pytest. It is working perfectly fine when I do </p>

<blockquote>
  <p>python test_server.py</p>
</blockquote>

<p>and then, </p>

<blockquote>
  <p>python test_client.py</p>
</blockquote>

<p>if you want to test your client functions you should actually mock server responses. If you want to run some integration tests for client. Then start your server with:</p>

<pre><code>python test_server.py
</code></pre>

<p>and run your client tests as:</p>

<pre><code>py.test test_client.py
</code></pre>

<p>py.test only runs functions which names are starting from test_ , so my guess that your server does not even start with pytest.</p>

python sockets py.test