Hi all
We have a bunch of functional tests derived from
StaticLiveServerTestCase using selenium that have started failing
after upgrading from Django 1.8 to Django 1.11.
The database is initially populated via data migrations, but after
running one test it all the data loaded via migrations has been
removed from the database, and all subsequent tests fail because the
expected data is not in the database.
Note that this is after running one test, not one test case; if we run
each test from an affected test case individually, they pass; if we
run the entire test case, the first test passes and the rest fail.
These tests were initially written under Django 1.8, with the data
coming from the same migrations, and they worked correctly in Django
1.8.
I looked back through the release notes and documentation; rollback
emulation[1] via serialized_rollback=True appeared promising, but
after enabling it we had IntegrityErrors immediately after finishing
the first test; it appears as though when it was attempting to re-load
the serialized data back in to the database, the data was still there:
Any thoughts? I've included some of the output below - running without
serialized_rollback[2] and with[3]. Unfortunately, I cannot share much
of the code itself.
Cheers
Tom
[1]
https://docs.djangoproject.com/en/1.11/topics/testing/overview/#rollback-emulation
[2]
tests.functional_tests.test_search_defaults.DefaultSearchResultsTest
test_browsing_to_a_saved_search_keeps_the_default_hero_block ...
[, , ]
ok
test_infinite_scrolling_of_search_results ... []
ERROR
screenshotting to
/home/london/te/moat-effortless_web_app/reports/screendumps/DefaultSearchResultsTest.test_infinite_scrolling_of_search_results-window0-2
018-02-23T11.59.55.png
dumping page HTML to
/home/london/te/moat-effortless_web_app/reports/screendumps/DefaultSearchResultsTest.test_infinite_scrolling_of_search_results-window
0-2018-02-23T11.59.55.html
writing har log to
/home/london/te/moat-effortless_web_app/reports/screendumps/DefaultSearchResultsTest.test_infinite_scrolling_of_search_results-window0-
2018-02-23T11.59.55.har.logwriting browser log to
/home/london/te/moat-effortless_web_app/reports/screendumps/DefaultSearchResultsTest.test_infinite_scrol
ling_of_search_results-window0-2018-02-23T11.59.55.browser.logLast URL
visited was http://dev-vip04.london.mintel.ad:53066/facelift/
http requests made during test:
==
ERROR: test_infinite_scrolling_of_search_results
(tests.functional_tests.test_search_defaults.DefaultSearchResultsTest)
--
Traceback (most recent call last):
File
"/data/home/london/te/moat-effortless_web_app/web_app/tests/functional_tests/test_search_defaults.py",
line 10, in test_infinite_scrolling_of_searc
h_results
homepage = HomePage.browse_to_directly(self)
File
"/data/home/london/te/moat-effortless_web_app/web_app/tests/functional_tests/pages/base.py",
line 61, in browse_to_directly
page.wait_for_page_load()
File
"/data/home/london/te/moat-effortless_web_app/web_app/tests/functional_tests/pages/home.py",
line 248, in wait_for_page_load
self.test.waitFor(_assert_page_ready)
File
"/data/home/london/te/moat-effortless_web_app/web_app/tests/functional_tests/base.py",
line 394, in waitFor
return function_with_assertion(*args)
File
"/data/home/london/te/moat-effortless_web_app/web_app/tests/functional_tests/pages/home.py",
line 246, in _assert_page_ready
'div.home-page'
File
"/data/home/london/te/moat-effortless_web_app/env/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py",
line 397, in find_element_by_css_selector
return self.find_element(by=By.CSS_SELECTOR, value=css_selector)
File
"/data/home/london/te/moat-effortless_web_app/env/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py",
line 707, in find_element
{'using': by, 'value': value})['value']
File
"/data/home/london/te/moat-effortless_web_app/env/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py",
line 196, in execute
self.error_handler.check_response(response)
File
"/data/home/london/te/moat-effortless_web_app/env/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py",
line 181, in check_response
raise exception_class(message, screen, stacktrace)
NoSuchElementException: Message: {"errorMessage":"Unable to find
element with css selector
'div.home-page'","request":{"headers":{"Accept":"application/json","Accept-Encoding":"identity","Connection":"close","Content-Length":"104","Content-Type":"application/json;charset=UTF-8","Host":"127.0.0.1:38766","User-Agent":"Python-urllib/2.7"},"httpVersion":"1.1","method":"POST","post":"{\"using\":
\"css selector\", \"sessionId\":
\"073fdaf0-1891-11e8-aa90-778d14a3b7d7\", \"value\":