2

Background

I'm trying to replace fixtures in my unit tests with model factories (using Factory Boy). It would help for me to determine why the current unit tests are failing if I could look at the database generated by loading the fixtures and compare them to the data generated by the factories.

I have tried to use the --keepdb flag when running the tests to save a copy of the test database but this doesn't seem to save an accessible database anywhere.

Question

Django test databases are discarded after the tests run. Is there any way to save a copy of a database before it is deleted?

Alternatively, is there a better way to compare the data created by a fixture file and the data created by a model factory?

Jack
  • 21
  • 3
  • 1
    can you add a breakpoint in your tests, then look at the database values? – James Russo Aug 02 '16 at 21:39
  • @JamesRusso I believe a test database exists only in memory. How would I access the database to view the values? – Jack Aug 02 '16 at 22:27
  • I haven't worked with Django yet, but I know in ruby on rails the test database actually exists when you run tests and can be accessible for queries. At my work we have a postgresql database and there is a test database that is accessible that is loaded with our fixtures when running tests and you can query it during tests. I would it assume it would be similar for Django but could be wrong – James Russo Aug 03 '16 at 03:40

0 Answers0