.. _plugins: ãã©ã°ã¤ã³ã¨ conftest ãã¡ã¤ã«ã®é£æº ==================================== .. Working with plugins and conftest files ============================================= .. py.test implements all aspects of configuration, collection, running and reporting by calling `well specified hooks`_. Virtually any Python module can be registered as a plugin. It can implement any number of hook functions (usually two or three) which all have a ``pytest_`` prefix, making hook functions easy to distinguish and find. There are three basic locations types: py.test 㯠:ref:`ããç·´ããããã㯠<well specified hooks>` ãå¼ã³åºããã¨ã«ãããè¨å®ãã³ã¬ã¯ã·ã§ã³ãå®è¡ãã¬ãã¼ãã®å ¨ç®æã§å¦çãå®è£ ãã¾ããäºå®ä¸ãä»»æã® Python ã¢ã¸ã¥ã¼ã«ããã©ã°ã¤ã³ã¨ãã¦ç»é²ã§ãã¾ãããã®ãã©ã°ã¤ã³ã¯ãããã¯é¢æ°ã®åºå¥ãæ¤åºã容æã«ã㦠``pytest_`` ã¨ããæ¥é è¾ããã¤å ¨ããã¯é¢æ°ããä»»æã®ããã¯é¢æ° (é常ã¯2ã¤ã3ã¤) ãå®è£ ãã¾ãã3ã¤ã®åºæ¬çãªé ç½®å ´æãããã¾ã: .. * `builtin plugins`_: loaded from py.test's own ``pytest/plugin`` directory. * `external plugins`_: modules discovered through `setuptools entry points`_ * `conftest.py plugins`_: modules auto-discovered in test directories * :ref:`çµã¿è¾¼ã¿ãã©ã°ã¤ã³ <builtin plugins>`: py.test ãã㤠``pytest/plugin`` ãã£ã¬ã¯ããªããèªã¿è¾¼ã * :ref:`å¤é¨ãã©ã°ã¤ã³ <external plugins>`: :ref:`setuptools ã®ã¨ã³ããªã¼ãã¤ã³ã <setuptools entry points>` ããã¢ã¸ã¥ã¼ã«ãæ¤åº * :ref:`conftest.py ãã©ã°ã¤ã³ <conftest.py plugins>`: ãã¹ããã£ã¬ã¯ããªããèªåçã«ã¢ã¸ã¥ã¼ã«ãæ¤åº .. _`pytest/plugin`: http://bitbucket.org/hpk42/pytest/src/tip/pytest/plugin/ .. _`conftest.py plugins`: .. _`conftest.py`: .. _`localplugin`: .. _`conftest`: conftest.py: ãã£ã¬ã¯ããªæ¯ã®ãã¼ã«ã«ãã©ã°ã¤ã³ ----------------------------------------------- .. conftest.py: local per-directory plugins -------------------------------------------------------------- .. local ``conftest.py`` plugins contain directory-specific hook implementations. Session and test running activities will invoke all hooks defined in ``conftest.py`` files closer to the root of the filesystem. Example: Assume the following layout and content of files:: ãã¼ã«ã«ã® ``conftest.py`` ãã©ã°ã¤ã³ã¯ããã£ã¬ã¯ããªåºæã®ããã¯å®è£ ãå«ã¿ã¾ããã»ãã·ã§ã³ã¨ãã¹ãã®å®è¡å¦çã¯ããã¡ã¤ã«ã·ã¹ãã ã®ã«ã¼ããã£ã¬ã¯ããªã«è¿ã ``conftest.py`` ãã¡ã¤ã«ã§å®ç¾©ãããå ¨ã¦ã®ããã¯ãå®è¡ãã¾ãããã¡ã¤ã«ã次ã®å ´æã«ç½®ãã¨ä»®å®ãã¦ãã ãã:: a/conftest.py: def pytest_runtest_setup(item): # 'a' ãã£ã¬ã¯ããªã«ããåãã¹ãã®å®è¡åãã«å¼ã°ãã print ("setting up", item) a/test_in_subdir.py: def test_sub(): pass test_flat.py: def test_flat(): pass .. Here is how you might run it:: ãã®ã³ã¼ãã®å®è¡æ¹æ³ã§ã:: py.test test_flat.py # "setting up" ã表示ããªã py.test a/test_sub.py # "setting up" ã表示 .. Note:: .. If you have ``conftest.py`` files which do not reside in a python package directory (i.e. one containing an ``__init__.py``) then "import conftest" can be ambiguous because there might be other ``conftest.py`` files as well on your PYTHONPATH or ``sys.path``. It is thus good practise for projects to either put ``conftest.py`` under a package scope or to never import anything from a conftest.py file. Python ããã±ã¼ã¸ãã£ã¬ã¯ã㪠(ä¾ãã° ``__Init__.py`` ãå«ããã£ã¬ã¯ããª) ã«ç½®ããã¦ãªã ``conftest.py`` ãã¡ã¤ã«ãããå ´åãPYTHONPATH ã¾ã㯠``sys.path`` ã«åãååããã¤å¥ã® ``conftest.py`` ãã¡ã¤ã«ãç½®ãå¯è½æ§ãããã"import conftest" ãææ§ã«ãªãã¨ããããã¾ãããããã£ãããã¸ã§ã¯ãã§ã¯ãããã±ã¼ã¸ã¹ã³ã¼ãã®ä¸ã§ ``conftest.py`` ãç½®ãã ``conftest.py`` ãã¡ã¤ã«ãã決ãã¦ã¤ã³ãã¼ãããªããã®ã©ã¡ããä¸æ¹ãé¸æããã®ãè¯ããã©ã¯ãã£ã¹ã§ãã .. _`external plugins`: .. _`extplugins`: å¤é¨ãã©ã°ã¤ã³ã®ã¤ã³ã¹ãã¼ã«ã¨æ¢ç´¢ ---------------------------------- .. Installing External Plugins / Searching ------------------------------------------------------ .. Installing a plugin happens through any usual Python installation tool, for example:: ãã©ã°ã¤ã³ã®ã¤ã³ã¹ãã¼ã«ã¯ãæ®éã® Python ã¤ã³ã¹ãã¼ã«ãã¼ã«ã使ã£ã¦è¡ãã¾ããä¾ãã°:: pip install pytest-NAME pip uninstall pytest-NAME .. If a plugin is installed, py.test automatically finds and integrates it, there is no need to activate it. Here is a list of known plugins: ãã©ã°ã¤ã³ãã¤ã³ã¹ãã¼ã«æ¸ã¿ãªããpy.test ãèªåçã«æ¤åºãã¦ãã®ãã©ã°ã¤ã³ãçµã¿è¾¼ã¿ã¾ãããã©ã°ã¤ã³ãæå¹åããå¿ è¦ã¯ããã¾ãããæ¢ç¥ã®ãã©ã°ã¤ã³ä¸è¦§ãç´¹ä»ãã¾ã: .. * `pytest-capturelog <http://pypi.python.org/pypi/pytest-capturelog>`_: to capture and assert about messages from the logging module * `pytest-capturelog <http://pypi.python.org/pypi/pytest-capturelog>`_: logging ã¢ã¸ã¥ã¼ã«ããã®ã¡ãã»ã¼ã¸ã«é¢ããã¢ãµã¼ãããã£ãã㣠.. * `pytest-xdist <http://pypi.python.org/pypi/pytest-xdist>`_: to distribute tests to CPUs and remote hosts, looponfailing mode, see also :ref:`xdist` * `pytest-xdist <http://pypi.python.org/pypi/pytest-xdist>`_: CPU ããªã¢ã¼ããã¹ãã使ã£ãåæ£ãã¹ãã :ref:`xdist` ãåç § .. * `pytest-cov <http://pypi.python.org/pypi/pytest-cov>`_: coverage reporting, compatible with distributed testing * `pytest-cov <http://pypi.python.org/pypi/pytest-cov>`_: åæ£ãã¹ãã§ã®äºææ§ãã«ãã¬ãã¸ã¬ãã¼ã .. * `pytest-pep8 <http://pypi.python.org/pypi/pytest-pep8>`_: a ``--pep8`` option to enable PEP8 compliance checking. * `pytest-pep8 <http://pypi.python.org/pypi/pytest-pep8>`_: ``--pep8`` ãªãã·ã§ã³ã使ã£ã PEP8 è¦ç´ãã§ã㯠.. * `oejskit <http://pypi.python.org/pypi/oejskit>`_: a plugin to run javascript unittests in life browsers (**version 0.8.9 not compatible with pytest-2.0**) * `oejskit <http://pypi.python.org/pypi/oejskit>`_: å®éã®ãã©ã¦ã¶ã¼ã§ javascript ã® unittests ãå®è¡ãããã©ã°ã¤ã³ (**ãã¼ã¸ã§ã³ 0.8.9 㯠pytest-2.0 ã§ã¯äºææ§ãããã¾ãã** ) .. You may discover more plugins through a `pytest- pypi.python.org search`_. `"pytest-" 㧠pypi.python.org ãæ¤ç´¢`_ ããã¨ããã£ã¨ãã©ã°ã¤ã³ãè¦ã¤ããã§ãããã .. _`available installable plugins`: .. _`pytest- pypi.python.org search`: http://pypi.python.org/pypi?%3Aaction=search&term=pytest-&submit=search .. _`"pytest-" 㧠pypi.python.org ãæ¤ç´¢`: http://pypi.python.org/pypi?%3Aaction=search&term=pytest-&submit=search ãµã³ãã«ã«ãããã©ã°ã¤ã³ã®è¨è¿° ------------------------------ .. Writing a plugin by looking at examples ------------------------------------------------------ .. _`Distribute`: http://pypi.python.org/pypi/distribute .. _`setuptools`: http://pypi.python.org/pypi/setuptools .. If you want to write a plugin, there are many real-life examples you can copy from: èªåã§ãã©ã°ã¤ã³ãä½æããããªããããããããå®éã®ãã©ã°ã¤ã³ãã³ãã¼ãã¦ããå§ããã¨è¯ãã§ã: .. * a custom collection example plugin: :ref:`yaml plugin` * around 20 `builtin plugins`_ which comprise py.test's own functionality * around 10 `external plugins`_ providing additional features * ã«ã¹ã¿ã ã³ã¬ã¯ã·ã§ã³ã®ãµã³ãã«ãã©ã°ã¤ã³: :ref:`yaml ãã©ã°ã¤ã³ <yaml plugin>` * py.test ã®ç¬èªæ©è½ãæ§æããç´20åã® :ref:`çµã¿è¾¼ã¿ãã©ã°ã¤ã³ <builtin plugins>` * 追å æ©è½ãæä¾ããç´10åã® :ref:`å¤é¨ãã©ã°ã¤ã³ <external plugins>` .. All of these plugins implement the documented `well specified hooks`_ to extend and add functionality. ãããã®å ¨ãã©ã°ã¤ã³ã¯ãæ©è½ã追å ï¼æ¡å¼µããããã«ããã¥ã¡ã³ãä»ãã® :ref:`ããç·´ããããã㯠<well specified hooks>` ãå®è£ ãã¾ãã .. _`setuptools entry points`: ç¬èªãã©ã°ã¤ã³ãä»ããã¤ã³ã¹ãã¼ã«å¯è½ã«ãã -------------------------------------------- .. Making your plugin installable by others ----------------------------------------------- .. If you want to make your plugin externally available, you may define a so-called entry point for your distribution so that ``py.test`` finds your plugin module. Entry points are a feature that is provided by `setuptools`_ or `Distribute`_. py.test looks up the ``pytest11`` entrypoint to discover its plugins and you can thus make your plugin available by definig it in your setuptools/distribute-based setup-invocation: èªåã§ä½æãããã©ã°ã¤ã³ãå¤é¨ããå©ç¨ã§ããããã«ããããªãã ``py.test`` ããã©ã°ã¤ã³ã¢ã¸ã¥ã¼ã«ãè¦ã¤ããããããã«ããã£ã¹ããªãã¥ã¼ã·ã§ã³ã®ããããã¨ã³ããªã¼ãã¤ã³ããå®ç¾©ãã¾ããã¨ã³ããªã¼ãã¤ã³ã㯠`setuptools`_ ã¾ã㯠`distribute`_ ãæä¾ããæ©è½ã§ããpy.test ã¯ããã©ã°ã¤ã³ãæ¤åºããããã« ``pytest11`` ã¨ããã¨ã³ããªã¼ãã¤ã³ãã調ã¹ã¾ãããã®ããã« setuptools/distribute ã® setup å¦çã§ã¨ã³ããªã¼ãã¤ã³ããå®ç¾©ãããã¨ã«ãããèªåã®ãã©ã°ã¤ã³ãå©ç¨ã§ãã¾ãã .. sourcecode:: python # ãµã³ãã«ã® ./setup.py ãã¡ã¤ã« from setuptools import setup setup( name="myproject", packages = ['myproject'] # 次ã®ããã«è¨è¿°ã㦠py.test ãããã©ã°ã¤ã³ãå©ç¨å¯è½ã«ãã entry_points = { 'pytest11': [ 'name_of_plugin = myproject.pluginmodule', ] }, ) .. If a package is installed this way, py.test will load ``myproject.pluginmodule`` as a plugin which can define `well specified hooks`_. ããã±ã¼ã¸ããã®æ¹æ³ã§ã¤ã³ã¹ãã¼ã«ãããå ´åãpy.test 㯠:ref:`ããç·´ããããã㯠<well specified hooks>` ãå®ç¾©ãããã©ã°ã¤ã³ã¨ã㦠``myproject.pluginmodule`` ãèªã¿è¾¼ã¿ã¾ãã .. Plugin discovery order at tool startup -------------------------------------------- ãã¼ã«èµ·åæã®ãã©ã°ã¤ã³æ¤åºé åº -------------------------------- .. py.test loads plugin modules at tool startup in the following way: py.test ã¯ã次ã®æ¹æ³ã§ãã¼ã«èµ·åæã«ãã©ã°ã¤ã³ã¢ã¸ã¥ã¼ã«ãèªã¿è¾¼ã¿ã¾ãã .. * by loading all builtin plugins * å ¨ã¦ã®çµã¿è¾¼ã¿ãã©ã°ã¤ã³ãèªã¿è¾¼ãã .. * by loading all plugins registered through `setuptools entry points`_. * :ref:`setuptools ã®ã¨ã³ããªã¼ãã¤ã³ã <setuptools entry points>` ããç»é²ãããå ¨ã¦ã®ãã©ã°ã¤ã³ãèªã¿è¾¼ãã .. * by pre-scanning the command line for the ``-p name`` option and loading the specified plugin before actual command line parsing. * ã³ãã³ãã©ã¤ã³ã® ``-p name`` ãªãã·ã§ã³ãäºåã«èª¿ã¹ãå®éã«ã³ãã³ãã©ã¤ã³ã®å¼æ°è§£æãè¡ãåã«æå®ãããã©ã°ã¤ã³ãèªã¿è¾¼ãã .. * by loading all :file:`conftest.py` files as inferred by the command line invocation (test files and all of its *parent* directories). Note that ``conftest.py`` files from *sub* directories are by default not loaded at tool startup. * ã³ãã³ãã©ã¤ã³ã®å®è¡ã§æ¨å®ãããå ¨ã¦ã® :file:`conftest.py` ãã¡ã¤ã«ãèªã¿è¾¼ã (ãã¹ããã¡ã¤ã«ã¨å ¨ã¦ã® *親* ãã£ã¬ã¯ããª) ã *ãµã* ãã£ã¬ã¯ããªããã® ``conftest.py`` ãã¡ã¤ã«ã¯ãããã©ã«ãã§ã¯ããã¼ã«ã®èµ·åæã«èªã¿è¾¼ã¾ããªããã¨ã«æ³¨æãã¦ãã ããã .. * by recursively loading all plugins specified by the ``pytest_plugins`` variable in ``conftest.py`` files * ``conftest.py`` ãã¡ã¤ã«ã® ``pytest_plugins`` å¤æ°ã§æå®ãããå ¨ã¦ã®ãã©ã°ã¤ã³ãå帰çã«èªã¿è¾¼ã ãã¹ãã¢ã¸ã¥ã¼ã«ã¾ã㯠conftest ãã¡ã¤ã«ã®ãã©ã°ã¤ã³ã®è¦æ±ã¨èªã¿è¾¼ã¿ -------------------------------------------------------------------- .. Requiring/Loading plugins in a test module or conftest file ------------------------------------------------------------- .. You can require plugins in a test module or a conftest file like this:: ãã¹ãã¢ã¸ã¥ã¼ã«ãã¾ã㯠conftest ãã¡ã¤ã«å ã§ãã©ã°ã¤ã³ãè¦æ±ã§ãã¾ã:: pytest_plugins = "name1", "name2", .. When the test module or conftest plugin is loaded the specified plugins will be loaded as well. You can also use dotted path like this:: ãã¹ãã¢ã¸ã¥ã¼ã«ãã¾ã㯠conftest ãã©ã°ã¤ã³ãèªã¿è¾¼ã¾ããã¨ããæå®ãããã©ã°ã¤ã³ãåæ§ã«èªã¿è¾¼ã¾ãã¾ããããã«æ¬¡ã®ããã«ãããåºåãã®ãã¹ã使ãã¾ã:: pytest_plugins = "myapp.testsupport.myplugin" .. which will import the specified module as a py.test plugin. ãã㯠py.test ãã©ã°ã¤ã³ã¨ãã¦æå®ããã¢ã¸ã¥ã¼ã«ãã¤ã³ãã¼ããã¾ãã .. Accessing another plugin by name -------------------------------------------- ãã©ã°ã¤ã³åã§å¥ã®ãã©ã°ã¤ã³ã¸ã¢ã¯ã»ã¹ -------------------------------------- .. If a plugin wants to collaborate with code from another plugin it can obtain a reference through the plugin manager like this: ãããã©ã°ã¤ã³ã¨å¥ã®ãã©ã°ã¤ã³ã®ã³ã¼ããå調ãããããªãã次ã®ããã«ãã©ã°ã¤ã³ããã¼ã¸ã£ã¼ã使ã£ã¦ãªãã¡ã¬ã³ã¹ãåå¾ã§ãã¾ã: .. sourcecode:: python plugin = config.pluginmanager.getplugin("name_of_plugin") .. If you want to look at the names of existing plugins, use the ``--traceconfig`` option. æ¢åã®ãã©ã°ã¤ã³åã調ã¹ããå ´å㯠``--traceconfig`` ãªãã·ã§ã³ã使ã£ã¦ãã ããã .. _`findpluginname`: æå¹ãªãã©ã°ã¤ã³ã®æ¤åº ---------------------- .. Finding out which plugins are active ---------------------------------------------------------------------------- .. If you want to find out which plugins are active in your environment you can type:: èªåã®ç°å¢ã§æå¹ãªãã©ã°ã¤ã³ã調ã¹ãããªãã次ã®ããã«å®è¡ãã¦ãã ãã:: py.test --traceconfig .. and will get an extended test header which shows activated plugins and their names. It will also print local plugins aka :ref:`conftest.py <conftest>` files when they are loaded. æå¹ãªãã©ã°ã¤ã³ã¨ãã®ååã表示ããæ¡å¼µãã¹ããããã¼ãåå¾ãã¾ãã :ref:`conftest.py <conftest>` ãèªã¿è¾¼ã¾ããã¨ãã«ãã®ãã¼ã«ã«ãã©ã°ã¤ã³ã表示ãã¾ãã .. _`cmdunregister`: ååãããã©ã°ã¤ã³ã®ç¡å¹åãç»é²è§£é¤ ------------------------------------ .. Deactivating / unregistering a plugin by name ---------------------------------------------------------------------------- .. You can prevent plugins from loading or unregister them:: ãã©ã°ã¤ã³ãèªã¿è¾¼ã¾ããªããã¾ãã¯ç»é²ã解é¤ã§ãã¾ã:: py.test -p no:NAME .. This means that any subsequent try to activate/load the named plugin will it already existing. See :ref:`findpluginname` for how to obtain the name of a plugin. ãã®ãªãã·ã§ã³ã¯ãæå¹åï¼èªã¿è¾¼ããã¨ãããã©ã°ã¤ã³ãæ¢ã«åå¨ãããã®ã¨ãã¦æ±ãã¾ãããã©ã°ã¤ã³åãåå¾ããæ¹æ³ã¯ :ref:`findpluginname` ãåç §ãã¦ãã ããã .. _`builtin plugins`: py.test ã®ããã©ã«ãã®ãã©ã°ã¤ã³ãªãã¡ã¬ã³ã¹ ============================================ .. py.test default plugin reference ==================================== .. You can find the source code for the following plugins in the `pytest repository <http://bitbucket.org/hpk42/pytest/>`_. 次ã®ãã©ã°ã¤ã³ã®ã½ã¼ã¹ã³ã¼ãã `pytest ãªãã¸ã㪠<http://bitbucket.org/hpk42/pytest/>`_ ã«å«ã¾ãã¦ãã¾ãã .. autosummary:: _pytest.assertion _pytest.capture _pytest.config _pytest.doctest _pytest.genscript _pytest.helpconfig _pytest.junitxml _pytest.mark _pytest.monkeypatch _pytest.nose _pytest.pastebin _pytest.pdb _pytest.pytester _pytest.python _pytest.recwarn _pytest.resultlog _pytest.runner _pytest.main _pytest.skipping _pytest.terminal _pytest.tmpdir _pytest.unittest .. _`well specified hooks`: py.test ã®ããã¯ãªãã¡ã¬ã³ã¹ ============================ .. py.test hook reference ==================================== .. Hook specification and validation ----------------------------------------- ããã¯ã®ä»æ§ã¨æ¤è¨¼ ------------------ .. py.test calls hook functions to implement initialization, running, test execution and reporting. When py.test loads a plugin it validates that each hook function conforms to its respective hook specification. Each hook function name and its argument names need to match a hook specification. However, a hook function may accept *fewer* parameters by simply not specifying them. If you mistype argument names or the hook name itself you get an error showing the available arguments. py.test ã¯ãåæåããã¹ãå®è¡ãã¬ãã¼ããå®è£ ããããã¯é¢æ°ãå¼ã³åºãã¾ããpy.test ããã©ã°ã¤ã³ãèªã¿è¾¼ãã¨ããåããã¯é¢æ°åã¯ãã®å¯¾å¿ããããã¯ä»æ§ã確èªãã¾ããåããã¯é¢æ°åã¨ãã®å¼æ°ã®ååã¯ãããã¯ä»æ§ã«ä¸è´ããå¿ è¦ãããã¾ããä½ããããã¯é¢æ°ãåã«æå®ããªããã¨ã«ãã *å°ãªã* ãã©ã¡ã¼ã¿ã¼ã¯è¨±å®¹ãã¾ããå¼æ°ã®ååãããã¯åãã®ãã®ãèª¤å ¥åããå ´åãå©ç¨ã§ããå¼æ°ã表示ããã¨ã©ã¼ã表示ããã¾ãã .. Initialization, command line and configuration hooks -------------------------------------------------------------------- åæåãã³ãã³ãã©ã¤ã³ãè¨å®ã®ãã㯠------------------------------------ .. currentmodule:: _pytest.hookspec .. autofunction:: pytest_cmdline_preparse .. autofunction:: pytest_cmdline_parse .. autofunction:: pytest_namespace .. autofunction:: pytest_addoption .. autofunction:: pytest_cmdline_main .. autofunction:: pytest_configure .. autofunction:: pytest_unconfigure .. Generic "runtest" hooks ------------------------------ æ±ç¨ç㪠"runtest" ãã㯠------------------------- .. All all runtest related hooks receive a :py:class:`pytest.Item` object. ããã¯ã«é¢é£ããå ¨ã¦ã® runtest 㯠:py:class:`pytest.Item` ãªãã¸ã§ã¯ããåãåãã¾ãã .. autofunction:: pytest_runtest_protocol .. autofunction:: pytest_runtest_setup .. autofunction:: pytest_runtest_call .. autofunction:: pytest_runtest_teardown .. autofunction:: pytest_runtest_makereport .. For deeper understanding you may look at the default implementation of these hooks in :py:mod:`_pytest.runner` and maybe also in :py:mod:`_pytest.pdb` which interacts with :py:mod:`_pytest.capture` and its input/output capturing in order to immediately drop into interactive debugging when a test failure occurs. ããæ·±ãç解ããã«ã¯ :py:mod:`_pytest.runner` ã®å®éã®ããã¯ã®ããã©ã«ãå®è£ ã調ã¹ããã¨ã«ãªãããããã¾ãããããã«ããã¹ãã失æããã¨ãã«ãã®ã¾ã¾å¯¾è©±å¼ã®ãããã¬ã¼ã«å ¥ãããã®å ¥åºåã®ãã£ããã£ã :py:mod:`_pytest.capture` ã¨ç¸äºã«ããåããã :py:mod:`_pytest.pdb` ããã£ã¨è¦ãããªãã§ãããã .. The :py:mod:`_pytest.terminal` reported specifically uses the reporting hook to print information about a test run. å®éã«ã¬ãã¼ããè¡ã :py:mod:`_pytest.terminal` ã¯ããã¹ãå®è¡ã«é¢ããæ å ±ã表示ããããã«ã¬ãã¼ãããã¯ã使ãã¾ãã .. Collection hooks ------------------------------ ã³ã¬ã¯ã·ã§ã³ã®ãã㯠-------------------- .. py.test calls the following hooks for collecting files and directories: py.test ã¯ãã¡ã¤ã«ã¨ãã£ã¬ã¯ããªãæ¢ç´¢ããããã«æ¬¡ã®ããã¯ãå¼ã³åºãã¾ã: .. autofunction:: pytest_ignore_collect .. autofunction:: pytest_collect_directory .. autofunction:: pytest_collect_file .. For influencing the collection of objects in Python modules you can use the following hook: Python ã¢ã¸ã¥ã¼ã«å ã®ãªãã¸ã§ã¯ãã®ã³ã¬ã¯ã·ã§ã³ã«å½±é¿ãä¸ããã«ã¯ã次ã®ããã¯ã使ãã¾ã: .. autofunction:: pytest_pycollect_makeitem .. Reporting hooks ------------------------------ ã¬ãã¼ããã㯠-------------- .. Session related reporting hooks: ã¬ãã¼ãããã¯ã«é¢é£ããã»ãã·ã§ã³: .. autofunction:: pytest_collectstart .. autofunction:: pytest_itemcollected .. autofunction:: pytest_collectreport .. autofunction:: pytest_deselected .. And here is the central hook for reporting about test execution: ããã¦ããã¹ãã®å®è¡ã«é¢ããä¸å¤®ã®ããã¯ã§ã: .. autofunction:: pytest_runtest_logreport .. Reference of important objects involved in hooks =========================================================== ããã¯ã§å®è¡ãããéè¦ãªãªãã¸ã§ã¯ãã®ãªãã¡ã¬ã³ã¹ ================================================== .. autoclass:: _pytest.config.Config :members: .. autoclass:: _pytest.config.Parser :members: .. autoclass:: _pytest.main.Node(name, parent) :members: .. .. autoclass:: _pytest.main.File(fspath, parent) :members: .. autoclass:: _pytest.main.Item(name, parent) :members: .. autoclass:: _pytest.python.Module(name, parent) :members: .. autoclass:: _pytest.python.Class(name, parent) :members: .. autoclass:: _pytest.python.Function(name, parent) :members: .. autoclass:: _pytest.runner.CallInfo :members: .. autoclass:: _pytest.runner.TestReport :members: