Background Image
Table of Contents Table of Contents
Previous Page  402 / 478 Next Page
Information
Show Menu
Previous Page 402 / 478 Next Page
Page Background

Cleaning up...

+ python manage.py test functional_tests

.....F.

======================================================================

FAIL: test_logged_in_users_lists_are_saved_as_my_lists

(functional_tests.test_my_lists.MyListsTest)

---------------------------------------------------------------------

Traceback (most recent call last):

File

"/var/lib/jenkins/jobs/Superlists/workspace/functional_tests/test_my_lists.py",

line 44, in test_logged_in_users_lists_are_saved_as_my_lists

self.assertEqual(self.browser.current_url, first_list_url)

AssertionError:

'http://localhost

:8081/accounts

/edith@example.com

/' !=

'http://localhost

:8081/lists/1/'

-

http://localhost

:8081/accounts

/edith@example.com/

+

http://localhost

:8081/lists/1/

---------------------------------------------------------------------

Ran 7 tests in 89.275s

FAILED (errors=1)

Creating test database for alias 'default'...

[{'secure': False, 'domain': 'localhost', 'name': 'sessionid', 'expiry':

1920011311, 'path': '/', 'value': 'a8d8bbde33nreq6gihw8a7r1cc8bf02k'}]

Destroying test database for alias 'default'...

Build step 'Virtualenv Builder' marked build as failure

Xvfb stopping

Finished: FAILURE

Pretty close! To debug that failure, we’ll need screenshots though.

As we’ll see, this error is due to a race condition, which means it’s not

always reproducible. You may see a different error, or none at all. In

any case, the tools below for taking screenshots and dealing with race

conditions will come in useful. Read on!

Taking Screenshots

To be able to debug unexpected failures that happen on a remote PC, it would be good

to see a picture of the screen at the moment of the failure, and maybe also a dump of

the HTML of the page. We can do that using some custom logic in our FT class

tear

Down

.We have to do a bit of introspection of

unittest

internals, a private attribute called

_outcomeForDoCleanups

, but this will work:

functional_tests/base.py (ch20l006).

import

os

from

datetime

import

datetime

SCREEN_DUMP_LOCATION

=

os

.

path

.

abspath

(

os

.

path

.

join

(

os

.

path

.

dirname

(

__file__

),

'screendumps'

)

)

[

...

]

374

|

Chapter 20: Continuous Integration (CI)