I have written some test cases for my project when I run these test cases, it creates test database for alias 'default' every time, after giving message then destroy database. I am concern only with message, So How to avoid creating test database, because it takes lots of time.
username$ ./manage.py test
...............
Some message, I Want only this message
...............
Creating test database for alias 'default'...
----------------------------------------------------------------------
Ran 0 tests in 0.000s
OK
Destroying test database for alias 'default'...
Just trick it to always skip with the argument True : @skipIf(True, "I don't want to run this test yet") def test_something(): ... If you are looking to simply not run certain test files, the best way is probably to use fab or other tool and run particular tests.
To help you get started, Django provides and uses a sample settings module that uses the SQLite database. See Using another settings module to learn how to use a different settings module to run the tests with a different database.
from the docs: When using SQLite, the tests will use an in-memory database by default (i.e., the database will be created in memory, bypassing the filesystem entirely!).
Yes, absolutely! Because our code that talks to the real DB is already tested carefully in the previous lecture. So all we need to do is: make sure that the mock DB implements the same interface as the real DB. Then everything will be working just fine when being put together.
Well, it's just a comment, not an answer yet - so I'll repeat the comment of Rahul Gupta:
Just subclass from SimpleTestCase
instead of TestCase
, see Django Testing Tools Documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With