.. Basic test configuration =================================== åºæ¬çãªãã¹ãã®è¨å® ==================== .. Command line options and configuration file settings ----------------------------------------------------------------- ã³ãã³ãã©ã¤ã³ãªãã·ã§ã³ã¨æ§æãã¡ã¤ã«ã®è¨å® -------------------------------------------- .. You can get help on command line options and values in INI-style configurations files by using the general help option:: ä¸è¬çãªãã«ããªãã·ã§ã³ã使ã£ã¦ãini ã¹ã¿ã¤ã«ã®æ§æãã¡ã¤ã«ã®ã³ãã³ãã©ã¤ã³ãªãã·ã§ã³ã¨ãã®å¤ã®ãã«ãã確èªã§ãã¾ã:: py.test -h # ãªãã·ã§ã³ã¨æ§æãã¡ã¤ã«ã®è¨å®ã表示 .. This will display command line and configuration file settings which were registered by installed plugins. ããã¯ã¤ã³ã¹ãã¼ã«æ¸ã¿ã®ãã©ã°ã¤ã³ãç»é²ããã³ãã³ãã©ã¤ã³è¨å®ã¨æ§æãã¡ã¤ã«è¨å®ã表示ãã¾ãã .. How test configuration is read from configuration INI-files ------------------------------------------------------------- INI æ§æãã¡ã¤ã«ãããã¹ãè¨å®ã®èªã¿è¾¼ã¿æ¹æ³ -------------------------------------------- .. py.test searches for the first matching ini-style configuration file in the directories of command line argument and the directories above. It looks for file basenames in this order:: py.test ã¯ãã³ãã³ãã©ã¤ã³å¼æ°ã®ãã£ã¬ã¯ããªã¨ãã®ä¸ä½ãã£ã¬ã¯ããªã®ãæåã«ä¸è´ãã ini ã¹ã¿ã¤ã«ã®æ§æãã¡ã¤ã«ãæ¤ç´¢ãã¾ãã次ã®é çªã§ãã¡ã¤ã«åãè¦ã¦ããã¾ã:: pytest.ini tox.ini setup.cfg .. Searching stops when the first ``[pytest]`` section is found. There is no merging of configuration values from multiple files. Example:: æåã® ``[pytest]`` ã®ã»ã¯ã·ã§ã³ãè¦ã¤ããã¨ãã«æ¤ç´¢ãä¸æ¢ãã¾ããè¤æ°ã®è¨å®ãã¡ã¤ã«ããè¨å®å¤ããã¼ã¸ãããããªãã¨ã¯ãã¾ããããµã³ãã«ãç´¹ä»ãã¾ã:: py.test path/to/testdir 次ã®ããã«æ§æãã¡ã¤ã«ãå«ããã£ã¬ã¯ããªãããã¾ã:: path/to/testdir/pytest.ini path/to/testdir/tox.ini path/to/testdir/setup.cfg path/to/pytest.ini path/to/tox.ini path/to/setup.cfg ... # ãã¡ã¤ã«ã·ã¹ãã ã®ã«ã¼ãã¾ã§ä¸ã .. If argument is provided to a py.test run, the current working directory is used to start the search. å¼æ°ã py.test ãå®è¡ããããã«æä¾ããããã®ãªããã«ã¬ã³ããã£ã¬ã¯ããªããã®æ¤ç´¢ã®éå§ä½ç½®ã«ä½¿ããã¾ãã .. _`how to change command line options defaults`: .. _`adding default options`: ã³ãã³ãã©ã¤ã³ãªãã·ã§ã³ã®ããã©ã«ãå¤ã®å¤æ´æ¹æ³ ------------------------------------------------ .. How to change command line options defaults ------------------------------------------------ .. It can be tedious to type the same series of command line options every time you use py.test . For example, if you always want to see detailed info on skipped and xfailed tests, as well as have terser "dot" progress output, you can write it into a configuration file:: py.test ã使ãã¨ãã«æ¯åä¸é£ã®ã³ãã³ãã©ã¤ã³ãªãã·ã§ã³ãå ¥åããã®ã¯é£½ã飽ããã¦ãã¾ããä¾ãã°ãæ¯åã¹ãããããã xfail ãããã¹ãã®è©³ç´°æ å ±ãè¦ãããªããé²æç¶æ³ãç°¡æ½ãª "ããã" åºåã«ããã®ã¨åæ§ã«ãæ§æãã¡ã¤ã«å ã«ãã®è¨å®ãè¨è¿°ã§ãã¾ã:: # pytest.ini ã®å 容 # (ã¾ã㯠tox.ini ã setup.cfg) [pytest] addopts = -rsxX -q .. From now on, running ``py.test`` will add the specified options. è¨å®å¾ã«å®è¡ãã㨠``py.test`` ã¯æå®ãããªãã·ã§ã³ã追å ãã¾ãã .. Builtin configuration file options ---------------------------------------------- çµã¿è¾¼ã¿ã®æ§æãã¡ã¤ã«ãªãã·ã§ã³ --------------------------------- .. confval:: minversion .. Specifies a minimal pytest version required for running tests. minversion = 2.1 # will fail if we run with pytest-2.0 ãã¹ãã®å®è¡ã«å¿ è¦ãª pytest ã®æå°ãã¼ã¸ã§ã³ãæå®ãã¾ã minversion = 2.1 # pytest-2.0 ã§å®è¡ããã¨å¤±æãã .. confval:: addopts .. Add the specified ``OPTS`` to the set of command line arguments as if they had been specified by the user. Example: if you have this ini file content:: [pytest] addopts = --maxfail=2 -rf # exit after 2 failures, report fail info issuing ``py.test test_hello.py`` actually means:: py.test --maxfail=2 -rf test_hello.py Default is to add no options. ã¦ã¼ã¶ã¼ãæå®ããããã«ã³ãã³ãã©ã¤ã³å¼æ°ãã»ããããã®ã«ç¹åãã ``OPTS`` ã追å ãã¾ãã次ã®ãã㪠ini ãã¡ã¤ã«ãããå ´å:: [pytest] addopts = --maxfail=2 -rf # 2å失æãããçµäºãã¦ããã®å 容ãã¬ãã¼ããã ``py.test test_hello.py`` ã¯ãå®éã«ã¯æ¬¡ã®å 容ã¨åãã§ã:: py.test --maxfail=2 -rf test_hello.py ããã©ã«ãã§ã¯ä½ã®ãªãã·ã§ã³ã追å ãã¾ããã .. confval:: norecursedirs .. Set the directory basename patterns to avoid when recursing for test discovery. The individual (fnmatch-style) patterns are applied to the basename of a directory to decide if to recurse into it. Pattern matching characters:: * matches everything ? matches any single character [seq] matches any character in seq [!seq] matches any char not in seq Default patterns are ``.* _* CVS {args}``. Setting a ``norecursedir`` replaces the default. Here is an example of how to avoid certain directories:: # content of setup.cfg [pytest] norecursedirs = .svn _build tmp* å帰çã«æ¢ç´¢ããªããã¹ããã£ã¬ã¯ããªã®ãã£ã¬ã¯ããªåã®ãã¿ã¼ã³ãè¨å®ãã¾ãããããã (fnmatch ã¹ã¿ã¤ã«) ã®ãã¿ã¼ã³ããã®ãã£ã¬ã¯ããªå ãå帰çã«èª¿ã¹ããã決ããã®ã«ãã£ã¬ã¯ããªåã«é©ç¨ããã¾ãããã¿ã¼ã³ãããã³ã°æåã¯æ¬¡ã®éãã§ã:: * å ¨ã¦ã«ä¸è´ãã ? ä»»æã®1æåã«ä¸è´ãã [seq] seq ã®ãã¡ä»»æã®1æåã«ä¸è´ãã [!seq] seq ã®ã©ã®æåã«ãä¸è´ããªã ããã©ã«ããã¿ã¼ã³ã¯ ``.* _* CVS {args}`` ã¨ãªã£ã¦ããã ``norecursedir`` ãè¨å®ãããã¨ã§ç½®ãæãããã¾ããç¹å®ã®ãã£ã¬ã¯ããªãæ¢ç´¢ããªãæ¹æ³ã®ãµã³ãã«ã¯æ¬¡ã®éãã§ã:: # setup.cfg ã®å 容 [pytest] norecursedirs = .svn _build tmp* ããã¯å ¸åç㪠subversion 㨠sphinx ã® build ãã£ã¬ã¯ããªã¨ ``tmp`` ã¨ããæ¥é è¾ããã¤ãã£ã¬ã¯ããªãå帰æ¢ç´¢ããªãè¨å®ã§ãã .. confval:: python_files .. One or more Glob-style file patterns determining which python files are considered as test modules. python ãã¡ã¤ã«ããã¹ãã¢ã¸ã¥ã¼ã«ã¨ã¿ãªãã1ã¤ããã以ä¸ã® Glob ã¹ã¿ã¤ã«ã®ãã¡ã¤ã«ãã¿ã¼ã³ã§ãã .. confval:: python_classes .. One or more name prefixes determining which test classes are considered as test modules. ãã¹ãã¯ã©ã¹ããã¹ãã¢ã¸ã¥ã¼ã«ã¨ã¿ãªãã1ã¤ããã以ä¸ã®æ¥é è¾ã§ãã .. confval:: python_functions .. One or more name prefixes determining which test functions and methods are considered as test modules. See :ref:`change naming conventions` for examples. ãã¹ãé¢æ°ãã¡ã½ããããã¹ãã¢ã¸ã¥ã¼ã«ã¨ã¿ãªãã1ã¤ããã以ä¸ã®æ¥é è¾ã§ãã :ref:`change naming conventions` ã®ãµã³ãã«ãã覧ãã ããã