(also, be aware if you're running your own tests here that you will only see an Spent re-creating the database at the beginning of the test run. Notice the time that Django reports is the almost the same in both cases, but theĪctual elapsed time is quite different - that's because Django isn't counting time Preserving test database for alias 'default'.Ħ.28user 0.36system 0:06.66elapsed 99%CPU Using existing test database for alias 'default'. You could use an environment variable for example, to make sure: Make sure you always run your test suite in CI against the real database. Django does a good job ofĪbstracting away 90% of those differences, but that still leaves plenty of strange edgeĬase behaviours to do with default values, ordering and transactions that can easily trip Don't do this in CIīut I'm only advocating this for use in development! Ultimately, Postgres or whicheverĭatabase you're using will behave differently from SQLite. This works pretty well in my experience, although I have had to blow away the testĭb in /dev/shm manually once or twice. I hear you ask? Django is smart enough to apply any new migrations to the So you get all the speed of an in-memory SQLite database, with the extra boost of not In linux, /dev/shm is actually aįilesystem against your machine's RAM, and it will persist between processes, OfĬourse, normally if you're using an in-memory database, keepdb doesn't makeĪny sense because memory disappears between runs. Since Django will use an in-memory sqlite database for tests, which is evenīut, especially if you have a large and complicated database, re-creating it with each Production database, using it for tests in dev is often a nice shortcut, particularly Although you're unlikely to be using SQLite as your argv : # and this allows you to use -keepdb to skip re-creating the db, # even faster! DATABASES = '/dev/shm/.sqlite3' More contextįor day-to-day development, running your tests needs to be as fast as possible to
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |