How can I configure my Django server to run tests from tests.py
when starting the server with python manage.py runserver
? Right now, I have to run tests through python manage.py test articles
. (Note: I am using Django 1.8)
Asked
Active
Viewed 261 times
2

Colby Gallup
- 328
- 1
- 2
- 10
-
4Create a bash alias or run them in sequence? – Henrik Andersson Nov 14 '15 at 21:22
-
`bash` alias is a way to go. – sobolevn Nov 14 '15 at 21:29
-
Not exactly what I was looking for, but it does work. I'll close this if I don't get another answer soon. Thank you! – Colby Gallup Nov 14 '15 at 21:54
-
why do you want to run tests when you start your server? – Louis Barranqueiro Nov 14 '15 at 22:12
-
@LouisBarranqueiro: Constant quality checking. It's also especially useful if I make changes to my models or HTML templates. – Colby Gallup Nov 14 '15 at 22:15
-
Possibly related to [this post](http://stackoverflow.com/questions/15166532/how-to-automatically-run-tests-when-theres-any-change-in-my-project-django) – Daniel Corin Nov 14 '15 at 22:33
-
@danielcorin: Almost related, but not quite. That post wants to run the test suite every time a change is applied, while I only want to run it every time I start the server. – Colby Gallup Nov 14 '15 at 22:37
1 Answers
1
Answer from @limelights:
Create a bash alias or run them in sequence?
I've adapted that answer to this line of code (for bash):
alias runserver="sudo python ~/testsite/manage.py test articles; sudo python ~/testsite/manage.py runserver 192.168.1.245:90
(as one line)
Using runserver
runs the test suite and opens the server. An added perk is that I can run it from any location without having to go into the ~/testsite
directory.

Colby Gallup
- 328
- 1
- 2
- 10