Note that there are some explanatory texts on larger screens.

plurals
  1. POGet name of current test in setup using nose
    primarykey
    data
    text
    <p>I am currently writing some functional tests using nose. The library I am testing manipulates a directory structure. </p> <p>To get reproducible results, I store a template of a test directory structure and create a copy of that before executing a test (I do that inside the tests <code>setup</code> function). This makes sure that I always have a well defined state at the beginning of the test.</p> <p>Now I have two further requirements:</p> <ol> <li>If a test fails, I would like the directory structure it operated on to <em>not</em> be overwritten or deleted, so that I can analyze the problem.</li> <li>I would like to be able to run multiple tests in parallel.</li> </ol> <p>Both these requirements could be solved by creating a new copy with a different name for each test that is executed. For this reason, I would like to get access to the name of the test that is currently executed in the <code>setup</code> function, so that I can name the copy appropriately. Is there any way to achieve this?</p> <p>An illustrative code example:</p> <pre><code>def setup_func(test_name): print "Setup of " + test_name def teardown_func(test_name): print "Teardown of " + test_name @with_setup(setup_func, teardown_func) def test_one(): pass @with_setup(setup_func, teardown_func) def test_two(): pass </code></pre> <p>Expected output:</p> <pre><code>Setup of test_one Teardown of test_one Setup of test_two Teardown of test_two </code></pre> <p>Injecting the name as a parameter would be the nicest solution, but I am open to other suggestions as well.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload