142 | | create_test_db(verbosity, autoclobber=not interactive) |
143 | | result = unittest.TextTestRunner(verbosity=verbosity).run(suite) |
144 | | destroy_test_db(old_name, verbosity) |
145 | | |
146 | | teardown_test_environment() |
147 | | |
148 | | return len(result.failures) + len(result.errors) |
149 | | |
150 | | No newline at end of file |
| 142 | test_database_name = create_test_db(verbosity, autoclobber=not interactive) |
| 143 | |
| 144 | import os |
| 145 | pid = os.fork() |
| 146 | if not pid: |
| 147 | # I am the child |
| 148 | from django.core.management import call_command |
| 149 | call_command('runserver', addrport="50003", shutdown_message="The test server is shutting down. Bye!", use_reloader=False) |
| 150 | else: |
| 151 | # I am the parent |
| 152 | result = unittest.TextTestRunner(verbosity=verbosity).run(suite) |
| 153 | destroy_test_db(old_name, verbosity) |
| 154 | teardown_test_environment() |
| 155 | # kill the child |
| 156 | os.kill(pid, 9) |
| 157 | # remove the sqlite database file |
| 158 | os.remove(test_database_name) |
| 159 | return len(result.failures) + len(result.errors) |
| 160 | |