About me

Sunday, June 24, 2018

python django Automatic Testing part 4

Know the testing output
The testing output of django here we will see that when we run our tests we will see number of test messages as the test runner prepares itself .Test runner is a component which orchestrates the execution of tests and provides the outcome to the user it may use a graphical interface a textual interface or return a special value to indicate the results of executing the tests
                    If you wish you can control the level of detail of these messages with the verbosity option on the command line like you can run tests with more detail (higher verbosity) by passing in the -v flag some of the other options are
-b,--buffer:
the standard output and standard error streams are buffered during the test run output during a passing test is discarded output is echoed normally on test fail or error and is added to the failure messages
-c,--catch:
     control c during the test run waits for the current test to end and then reports all the results so far A second control-c raises the normal KeyboardInterrupt exception
-f --failfast:
 stop the test run on the first error or failure
--locals:
   show local variables in tracebacks
and you can get all the command line options put -h as  
python -m unittest -h
here is an example of using -v

python -m unittest -v test_module
likewise we can use the options and after running the tests here
Creating test database...
Creating table myapp_database
Creating table myapp_mineral
This here tells you that the test runner is creating a test database as described in the previous posts once the database has been created Django will run your tests if every thing goes well we will see something like this as for example

----------------------------------------------------------------------

Ran 22 tests in 0.221s

OK
otherwise we will get error like this
======================================================================
FAIL: test_was_published_recently_with_future_poll (polls.tests.PollMethodTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/dev/mysite/polls/tests.py", line 16, in test_was_published_recently_with_future_poll
    self.assertIs(future_poll.was_published_recently(), False)
AssertionError: True is not False

----------------------------------------------------------------------
Ran 1 test in 0.003s

FAILED (failures=1)

To learn more about python unittest you can go to this link one thing to note here the return code for the test runner script is 1 for any number of failed and erroneous test if all tests pass the return code is 0 this feature is useful if you're using the test runner script in a shell script and need to test for success or failure at that level


 Thats for this post guys more on testing will be on next post please comment share and follow this blog

3 comments:

  1. I Think This Is Owsm Post, But If You Check This usd-rmb Review To Learn More About The Company, Their Products, And The Trading Platform. You Will Find Here How To Open An Account And How To Get Started Online Trading.

    ReplyDelete
  2. Forex Broker Canada Get Information On The Top Forex Brokers In Canada. Read Reviews, Compare The Best Trading Platforms, & Find The Right Broker For You.

    ReplyDelete
  3. We have a daily Thousands of unique visitors which come for information about online forex brokers, investing, economic news and currency trading in general. In the Regulated Forex Brokers In Malaysia search results you can find the best online forex brokers sorted by various criteria and we keep those results up to date at all times.

    ReplyDelete