Nosetest - get a list of failed tests (without additional output)

Is it possible to have a nasal output only the name of the tests that can not get a simple and compact list of failed tests?

I figured out how to discard a captured stdout:

nosetests -s 

but the statement that fails is still being printed (for example, assertEqual prints both the expected and the actual values). Ideally, I just want to know that the file and line failed.

+6
source share
1 answer

very quick and primitive answer to your question:

if you use the parameter - verbosity = 2 , it will list all your tests

if you redirect stderr to stdout you can get a text file ... something like this:

The example below will run inside the tests :

nosetests -s --verbosity = 2 test_tasks.py> mytestresults.txt 2> & 1

this will create a complete list of all your tests and whether they will pass or fail at the top of mytestresults.txt (you can trim all Assertion outputs, tracing, etc. for failed tests after receiving the list of tests from the top of mytestresults.txt)

sample below:

test_admin_users_can_complete_tasks_that_are_not_created_by_them (tests.test_tasks.TasksTests) ... ok

test_admin_users_can_delete_tasks_that_are_not_created_by_them (tests.test_tasks.TasksTests) ... ok

test_admin_users_can_see_task_modify_links_for_all_tasks (tests.test_tasks.TasksTests) ... FAIL

test_logged_in_users_can_access_tasks_page (tests.test_tasks.TasksTests) ... FAIL

test_not_logged_in_users_cannot_access_tasks_page (tests.test_tasks.TasksTests) ... ok

test_string_representation_of_the_task_object (tests.test_tasks.TasksTests) ... ERROR

test_task_template_displays_logged_in_user_name (tests.test_tasks.TasksTests) ... FAIL

test_users_can_add_tasks (tests.test_tasks.TasksTests) ... FAIL

test_users_can_complete_tasks (tests.test_tasks.TasksTests) ... FAIL

test_users_can_delete_tasks (tests.test_tasks.TasksTests) ... FAIL

test_users_can_see_task_modify_links_for_tasks_created_by_them (tests.test_tasks.TasksTests) ... FAIL

test_users_cannot_add_tasks_when_error (tests.test_tasks.TasksTests) ... FAIL

test_users_cannot_complete_tasks_that_are_not_created_by_them (tests.test_tasks.TasksTests) ... FAIL

test_users_cannot_delete_tasks_that_are_not_created_by_them (tests.test_tasks.TasksTests) ... FAIL

test_users_cannot_see_task_modify_links_for_tasks_not_created_by_them (tests.test_tasks.TasksTests) ... ok

... stack trace, etc. here (not shown for brevity) ...

EDIT: oops I wrote this, saved it, and then noticed that you need a line number - you have to parse it from the trace details ... or ...

A much more refined approach would be to use the Nose-progressive plugin to format the output as you like.

0
source

Source: https://habr.com/ru/post/924876/


All Articles