1

We use LiveServerTestCase with Selenium for integration tests of a multi-page user flow.

One of the flows is raising an exception at runtime, yet the test is passing. The exception is visible in the test logs, but does not cause the test to fail.

Simplified example:

class SmokeTest(LiveServerTestCase):
  def this_should_fail_but_passes(self):
    driver = webdriver.Chrome()
    driver.get('/home')
    # This test passes
class HomeView(TemplateView):
  def get(self, request, *args, **kwargs):
    raise Exception("You would think the test would fail, but it doesn't.")

Test passes, though exception is visible in logs...

   ...
    raise Exception("You would think the test would fail, but it doesn't.")
Exception: You would think the test would fail, but it doesn't.
.
----------------------------------------------------------------------
Ran 1 test in 2.248s

OK

The root cause seems to be that LiveServerTestCase launches a separate server instance and runtime errors that it experiences are logged, but do not bubble up as exceptions to the test client.

Darren Nix
  • 136
  • 1
  • 10

0 Answers0