dimanche 7 juin 2020

Getting nose's numeric test ID in a test

I have tests that I run with nose, and I'd like to make them run in parallel using the --processes flag. Every test opens a port which is configurable, and I'd like to calculate the port number based on the test number that appears in the printout when using the --with-id flag, as shown in the following example from here:

% nosetests -v --with-id
#1 tests.test_a ... ok
#2 tests.test_b ... ok
#3 tests.test_c ... ok

When looking for a solution I stumbled upon this answer, which uses self._testMethodName and self.id(), but those don't work for me because they're string IDs based on the test's name and path.

Is there a way where I can get the printed numeric ID that appears when using --with-id?

Aucun commentaire:

Enregistrer un commentaire