MCPcopy Create free account
hub / github.com/EasyIME/PIME / main

Function main

python/python3/tornado/testing.py:796–885  ·  view source on GitHub ↗

A simple test runner. This test runner is essentially equivalent to `unittest.main` from the standard library, but adds support for Tornado-style option parsing and log formatting. It is *not* necessary to use this `main` function to run tests using `AsyncTestCase`; these tests

(**kwargs: Any)

Source from the content-addressed store, hash-verified

794
795
796def main(**kwargs: Any) -> None:
797 """A simple test runner.
798
799 This test runner is essentially equivalent to `unittest.main` from
800 the standard library, but adds support for Tornado-style option
801 parsing and log formatting. It is *not* necessary to use this
802 `main` function to run tests using `AsyncTestCase`; these tests
803 are self-contained and can run with any test runner.
804
805 The easiest way to run a test is via the command line::
806
807 python -m tornado.testing tornado.test.web_test
808
809 See the standard library ``unittest`` module for ways in which
810 tests can be specified.
811
812 Projects with many tests may wish to define a test script like
813 ``tornado/test/runtests.py``. This script should define a method
814 ``all()`` which returns a test suite and then call
815 `tornado.testing.main()`. Note that even when a test script is
816 used, the ``all()`` test suite may be overridden by naming a
817 single test on the command line::
818
819 # Runs all tests
820 python -m tornado.test.runtests
821 # Runs one test
822 python -m tornado.test.runtests tornado.test.web_test
823
824 Additional keyword arguments passed through to ``unittest.main()``.
825 For example, use ``tornado.testing.main(verbosity=2)``
826 to show many test details as they are run.
827 See http://docs.python.org/library/unittest.html#unittest.main
828 for full argument list.
829
830 .. versionchanged:: 5.0
831
832 This function produces no output of its own; only that produced
833 by the `unittest` module (previously it would add a PASS or FAIL
834 log message).
835 """
836 from tornado.options import define, options, parse_command_line
837
838 define(
839 "exception_on_interrupt",
840 type=bool,
841 default=True,
842 help=(
843 "If true (default), ctrl-c raises a KeyboardInterrupt "
844 "exception. This prints a stack trace but cannot interrupt "
845 "certain operations. If false, the process is more reliably "
846 "killed, but does not print a stack trace."
847 ),
848 )
849
850 # support the same options as unittest's command-line interface
851 define("verbose", type=bool)
852 define("quiet", type=bool)
853 define("failfast", type=bool)

Callers 1

testing.pyFile · 0.70

Calls 3

defineFunction · 0.90
parse_command_lineFunction · 0.90
printFunction · 0.50

Tested by

no test coverage detected