سؤال

I'm using django 1.3 and writing some selenium test & django unit tests. I want to know if its possible to run the tests without creating the databases & loading fixtures everytime?

I stumbled upon this SO thread which gives a good way to test without creating a database but that still flushes the database fixtures & reloads them every time. I do not want even that to happen. I just want the tests to read / write the database I have set up once. I do not want it to create database / load fixtures every time I run any test.

I'd be glad to provide any further info if required to sort this out.

Thanks in advance! :)

هل كانت مفيدة؟

المحلول

I was able to do this by hacking into some django code. The parts that need to be edited is,

FILE: django/db/backends/sqlite3/creation.py

change the code as follows:

  1. setting confirm = 'yes' in line 55
  2. commenting out all occurrences of os.remove(test_database_name)

FILE: django/db/backends/creation.py

change the code as follows

  1. comment 359 to 376 (the syncdb & flush part in create_test_db function.
  2. almost everything in _create_test_db. (almost everything == code part which does the undesired stuff which we are trying to eliminate)
  3. almost everything in _destroy_test_db.
  4. almost everything in destroy_test_db.

Hope that helps!

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top