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.