Running tests in single Python file with nose
<p>I'm using nose 1.3.7 with Anaconda 4.1.1 (Python 3.5.2). I want to run unit tests in a single file, e.g. <code>foo.py</code>. According to the <a href="http://nose.readthedocs.io/en/latest/usage.html" rel="nofollow">documentation</a> I should be able to simply run:</p>

<pre><code>nosetests foo.py
</code></pre>

<p>But when I do this, nose runs all the tests in all the files in the directory!</p>

<p>And if I do <code>nose --help</code>, the usage documentation doesn't even indicate that there is a  parameter. It only shows [options].</p>

<p>So can I run tests in a single file using nose?</p>

<p>I have a standalone Python 3.4 version and <code>nosetests foo.py</code>  runs tests only in <code>foo.py</code> and <code>nosetests spam.py</code> runs test only in <code>spam.py</code>. </p>

<p>A plain <code>nosetests</code> command without any option specified, runs tests in all files with names starting with the word <code>test_</code> in the directory.</p>

<p>Here's quoting from their <a href="https://nose.readthedocs.io/en/latest/finding_tests.html" rel="nofollow">test discovery</a> documentation which specifies rules for test discovery.The last line of the documentation clarifies what could be the cause for your anomaly.</p>

<blockquote>
  <p>Be aware that plugins and command line options can change any of those
  rules.</p>
</blockquote>

<p>I suspect (and I may be wrong) that it has to do with how anaconda configures nose for your install.</p>

python unit-testing nose