Questions tagged [liveservertestcase]

LiveServerTestCase: LiveServerTestCase does basically the same as TransactionTestCase with one extra feature: it launches a live Django server in the background on setup, and shuts it down on teardown. This allows the use of automated test clients other than the Django dummy client such as, for example, the Selenium client, to execute a series of functional tests inside a browser and simulate a real user’s actions.

LiveServerTestCase

LiveServerTestCase does basically the same as TransactionTestCase with one extra feature: it launches a live Django server in the background on setup, and shuts it down on teardown. This allows the use of automated test clients other than the Django dummy client such as, for example, the Selenium client, to execute a series of functional tests inside a browser and simulate a real user’s actions.

The live server listens on localhost and binds to port 0 which uses a free port assigned by the operating system. The server’s URL can be accessed with self.live_server_url during the tests.

References

11 questions
20
votes
3 answers

Where to set value of liveServer.settings.port in live server extension of visual studio code

I am working on Angular7 with visual studio code editor URL: http://localhost:4200 (Working fine) But, I installed extension Live Server and when I click on Liveserver icon its giving me the error "Error on port 5500. Please try to change the…
10
votes
3 answers

Database still in use after a selenium test in Django

I have a Django project in which I'm starting to write Selenium tests. The first one looking like this: from django.contrib.staticfiles.testing import StaticLiveServerTestCase from selenium import webdriver from selenium.webdriver.common.keys import…
Pablo Fernandez
  • 279,434
  • 135
  • 377
  • 622
8
votes
1 answer

Why does mock patch only work when running specific test and not whole test suite?

I'm using Django and Pytest specifically to run the test suite and am trying to test that a specific form shows up with expected data when a user hits the site (integration test). This particular view uses a stored procedure, which I am mocking…
Hanny
  • 580
  • 3
  • 16
  • 44
4
votes
1 answer

django.db.utils.IntegrityError: FOREIGN KEY constraint failed while executing LiveServerTestCases through Selenium and Python Django

I can run all unit tests successfully, I can even run selenium tests successfully if I run an independent server, but when I try to use LiveServerTestCases to test everything in a self-contained manner, each LiveServerTestCase test ends with the…
2
votes
0 answers

Django LiveServerTestCase - Unable to force_login in multiple tests

Versions Django version: 1.9 Python: 3.5 Django Rest Framework: 3.5.4 Error Observed: Error Traceback (most recent call last): File "/Users/ds/git/some_repo/integration/test_multiple_login.py", line 32, in test_two …
Deep
  • 1,151
  • 11
  • 18
2
votes
2 answers

Selenium test priority in Flask

I have a use case in selenium in which the priority of test functions are important. I'm using LiveServerTestCase in flask for tests. In Java, there is a decorator @Test(priority=0) for defining test priorities. My question is what is the equivalent…
1
vote
0 answers

Exceptions not bubbling up from LiveServerTestCase

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…
Darren Nix
  • 136
  • 1
  • 10
1
vote
0 answers

How to generate a testing report in Django using selenium and LiveServerTestCase?

I have been using LiveServerTestCase to build test cases for my Django project for a month. Now, I am creating more test cases using Selenium and LiveServerTestCase together to test how my project runs automatically. I want to know how can I…
Alex Mak
  • 11
  • 1
1
vote
1 answer

vscode live Server port settings not work, and always open in localhost:8081

here is my live Server settings json { "editor.fontSize": 18, "workbench.iconTheme": "vscode-icons", "files.autoSave": "onFocusChange", "terminal.integrated.shell.windows":…
0
votes
0 answers

Selenium liveServerTestCase is using Test Database instead of Project database (Django)

I am beginning to try Django testing using selenium , I am following this tutorial Selenium | Django | Gentle Introduction, Setup and Start Testing while trying to run a simple login test case i am getting in the test browser: username and password…
0
votes
2 answers

Is it possible to login once for all LiveServerTestCases?

I would like to do something like this: class TestSuite(LiveServerTestCase): @classmethod def setUp(self): self.driver = webdriver.Chrome() # Login User self.driver.get(self.live_server_url +…
kaskenades
  • 25
  • 6