Make the runserver command run with code

MrSchrecklich

I want to start a server with the manage.py runserver command and I'm trying for some time now but don't really find the right way.

from subprocess import Popen, PIPE
from django.test import TestCase
import unittest
from selenium import webdriver
from selenium.webdriver.common.keys import Keys

class ExampleClass(TestCase):

  def startServer(self):
    process = Popen(['cd C:\mypath'], stdin=PIPE, stdout=PIPE)
    process.stdin.write(['python', 'manage.py runserver'])

.
.
.
  def test_examplename(self):
    self.browser.get('http://localhost:8000')

Everytime I start the test it seems like the process is starting in background but as soon as the browser window pops up it shows me a "can't connect" error. So the server is not running.

Please note that the test is working fine when I start the server myself.

Alasdair

I recommend you use LiveServerTestCase instead of TestCase for tests that use Selenium. Django will take care of starting and stopping the server, so you don't have to worry about it.

For more information and an example of a test case that uses Selenium, see the docs.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Make the runserver command run with code

From Dev

Make VisualStudio run a command to generate C# code

From Dev

How to compile and run code and make gnuplot instruction in a single command line

From Dev

Unable to run the `make` command

From Dev

command || run code and exit

From Dev

Django runserver command not working

From Dev

Django runserver command failed

From Dev

Why doesn't this bash script run as "sh runserver" recognize the "source" command?

From Dev

To make the following code run faster?

From Dev

Can't run make - gcc: command not found

From Dev

command line to make winforms run without UI

From Dev

Run artisan command (make: migration) in my controller

From Dev

Can't run make - gcc: command not found

From Dev

how to make an application to run from a command in terminal

From Dev

How to make a command not run as sudo in script

From Dev

Make ShellScript run with custom CLI command

From Dev

How to make a command run on startup on KDE Manjaro

From Dev

error while trying to run make command

From Dev

Error running "make" command in order to run darknet

From Dev

NodeJS - How do i make a command that will run after a command?

From Dev

Make a command run if the output of the previous command had a specific value

From Dev

Is there a way to make vim run the "make" command in another terminal window?

From Dev

Visual Studio Code command "dnx run" not available

From Dev

Run IntelliJ code formatter from the command line

From Dev

How to run sed command from java code

From Dev

How to run sed command from java code

From Dev

Uable to run manage.py runserver in Django

From Dev

How to run manage.py runserver in django

From Dev

Uable to run manage.py runserver in Django

Related Related

  1. 1

    Make the runserver command run with code

  2. 2

    Make VisualStudio run a command to generate C# code

  3. 3

    How to compile and run code and make gnuplot instruction in a single command line

  4. 4

    Unable to run the `make` command

  5. 5

    command || run code and exit

  6. 6

    Django runserver command not working

  7. 7

    Django runserver command failed

  8. 8

    Why doesn't this bash script run as "sh runserver" recognize the "source" command?

  9. 9

    To make the following code run faster?

  10. 10

    Can't run make - gcc: command not found

  11. 11

    command line to make winforms run without UI

  12. 12

    Run artisan command (make: migration) in my controller

  13. 13

    Can't run make - gcc: command not found

  14. 14

    how to make an application to run from a command in terminal

  15. 15

    How to make a command not run as sudo in script

  16. 16

    Make ShellScript run with custom CLI command

  17. 17

    How to make a command run on startup on KDE Manjaro

  18. 18

    error while trying to run make command

  19. 19

    Error running "make" command in order to run darknet

  20. 20

    NodeJS - How do i make a command that will run after a command?

  21. 21

    Make a command run if the output of the previous command had a specific value

  22. 22

    Is there a way to make vim run the "make" command in another terminal window?

  23. 23

    Visual Studio Code command "dnx run" not available

  24. 24

    Run IntelliJ code formatter from the command line

  25. 25

    How to run sed command from java code

  26. 26

    How to run sed command from java code

  27. 27

    Uable to run manage.py runserver in Django

  28. 28

    How to run manage.py runserver in django

  29. 29

    Uable to run manage.py runserver in Django

HotTag

Archive