Sophie

Sophie

distrib > Fedora > 18 > i386 > by-pkgid > c004b048a08dced45cdde088d7d8ef62 > files > 404

pytest-2.3.5-3.fc18.noarch.rpm



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>プラグインと conftest ファイルの連携</title>
    
    <link rel="stylesheet" href="_static/sphinxdoc.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '',
        VERSION:     '2.2.4.0',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/underscore.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>
    <script type="text/javascript" src="_static/translations.js"></script>
    <link rel="top" title="None" href="index.html" />
    <link rel="next" title="講演とチュートリアル" href="talks.html" />
    <link rel="prev" title="モジュールやテストファイルの doctest" href="doctest.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>ナビゲーション</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="py-modindex.html" title="Pythonモジュール索引"
             >モジュール</a></li>
        <li class="right" >
          <a href="talks.html" title="講演とチュートリアル"
             accesskey="N">次へ</a> |</li>
        <li class="right" >
          <a href="doctest.html" title="モジュールやテストファイルの doctest"
             accesskey="P">前へ</a> |</li>
        <li><a href="contents.html">pytest-2.2.4.0</a> &raquo;</li> 
      </ul>
    </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
  <h3><a href="contents.html">目次</a></h3>
  <ul>
<li><a class="reference internal" href="#">プラグインと conftest ファイルの連携</a><ul>
<li><a class="reference internal" href="#id1">conftest.py: ディレクトリ毎のローカルプラグイン</a></li>
<li><a class="reference internal" href="#extplugins">外部プラグインのインストールと探索</a></li>
<li><a class="reference internal" href="#id4">サンプルによるプラグインの記述</a></li>
<li><a class="reference internal" href="#setuptools-entry-points">独自プラグインを他からインストール可能にする</a></li>
<li><a class="reference internal" href="#id6">ツール起動時のプラグイン検出順序</a></li>
<li><a class="reference internal" href="#id7">テストモジュールまたは conftest ファイルのプラグインの要求と読み込み</a></li>
<li><a class="reference internal" href="#id8">プラグイン名で別のプラグインへアクセス</a></li>
<li><a class="reference internal" href="#findpluginname">有効なプラグインの検出</a></li>
<li><a class="reference internal" href="#cmdunregister">名前からプラグインの無効化や登録解除</a></li>
</ul>
</li>
<li><a class="reference internal" href="#py-test">py.test のデフォルトのプラグインリファレンス</a></li>
<li><a class="reference internal" href="#well-specified-hooks">py.test のフックリファレンス</a><ul>
<li><a class="reference internal" href="#id12">フックの仕様と検証</a></li>
<li><a class="reference internal" href="#id13">初期化、コマンドライン、設定のフック</a></li>
<li><a class="reference internal" href="#runtest">汎用的な &#8220;runtest&#8221; フック</a></li>
<li><a class="reference internal" href="#id14">コレクションのフック</a></li>
<li><a class="reference internal" href="#id15">レポートフック</a></li>
</ul>
</li>
<li><a class="reference internal" href="#id16">フックで実行される重要なオブジェクトのリファレンス</a></li>
</ul>

  <h4>前のトピックへ</h4>
  <p class="topless"><a href="doctest.html"
                        title="前の章へ">モジュールやテストファイルの doctest</a></p>
  <h4>次のトピックへ</h4>
  <p class="topless"><a href="talks.html"
                        title="次の章へ">講演とチュートリアル</a></p>
<div id="searchbox" style="display: none">
  <h3>クイック検索</h3>
    <form class="search" action="search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="検索" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    モジュール、クラス、または関数名を入力してください
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="conftest">
<span id="plugins"></span><h1>プラグインと conftest ファイルの連携<a class="headerlink" href="#conftest" title="このヘッドラインへのパーマリンク">¶</a></h1>
<p>py.test は <a class="reference internal" href="#well-specified-hooks"><em>よく練られたフック</em></a> を呼び出すことにより、設定、コレクション、実行、レポートの全箇所で処理を実装します。事実上、任意の Python モジュールをプラグインとして登録できます。このプラグインは、フック関数の区別や検出を容易にして <tt class="docutils literal"><span class="pre">pytest_</span></tt> という接頭辞をもつ全フック関数から任意のフック関数 (通常は2つか3つ) を実装します。3つの基本的な配置場所があります:</p>
<ul class="simple">
<li><a class="reference internal" href="#builtin-plugins"><em>組み込みプラグイン</em></a>: py.test がもつ <tt class="docutils literal"><span class="pre">pytest/plugin</span></tt> ディレクトリから読み込む</li>
<li><a class="reference internal" href="#external-plugins"><em>外部プラグイン</em></a>: <a class="reference internal" href="#setuptools-entry-points"><em>setuptools のエントリーポイント</em></a> からモジュールを検出</li>
<li><a class="reference internal" href="#conftest-py-plugins"><em>conftest.py プラグイン</em></a>: テストディレクトリから自動的にモジュールを検出</li>
</ul>
<div class="section" id="id1">
<span id="localplugin"></span><span id="conftest-py"></span><span id="conftest-py-plugins"></span><span id="id2"></span><h2>conftest.py: ディレクトリ毎のローカルプラグイン<a class="headerlink" href="#id1" title="このヘッドラインへのパーマリンク">¶</a></h2>
<p>ローカルの <tt class="docutils literal"><span class="pre">conftest.py</span></tt> プラグインは、ディレクトリ固有のフック実装を含みます。セッションとテストの実行処理は、ファイルシステムのルートディレクトリに近い <tt class="docutils literal"><span class="pre">conftest.py</span></tt> ファイルで定義された全てのフックを実行します。ファイルを次の場所に置くと仮定してください:</p>
<div class="highlight-python"><pre>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</pre>
</div>
<p>このコードの実行方法です:</p>
<div class="highlight-python"><pre>py.test test_flat.py   # "setting up" を表示しない
py.test a/test_sub.py  # "setting up" を表示</pre>
</div>
<div class="admonition note">
<p class="first admonition-title">ノート</p>
<p class="last">Python パッケージディレクトリ (例えば <tt class="docutils literal"><span class="pre">__Init__.py</span></tt> を含むディレクトリ) に置かれてない <tt class="docutils literal"><span class="pre">conftest.py</span></tt> ファイルがある場合、PYTHONPATH または <tt class="docutils literal"><span class="pre">sys.path</span></tt> に同じ名前をもつ別の <tt class="docutils literal"><span class="pre">conftest.py</span></tt> ファイルを置く可能性があり、&#8221;import conftest&#8221; が曖昧になるときがあります。こういったプロジェクトでは、パッケージスコープの中で <tt class="docutils literal"><span class="pre">conftest.py</span></tt> を置くか <tt class="docutils literal"><span class="pre">conftest.py</span></tt> ファイルから決してインポートしないかのどちらか一方を選択するのが良いプラクティスです。</p>
</div>
</div>
<div class="section" id="extplugins">
<span id="external-plugins"></span><span id="id3"></span><h2>外部プラグインのインストールと探索<a class="headerlink" href="#extplugins" title="このヘッドラインへのパーマリンク">¶</a></h2>
<p>プラグインのインストールは、普通の Python インストールツールを使って行います。例えば:</p>
<div class="highlight-python"><pre>pip install pytest-NAME
pip uninstall pytest-NAME</pre>
</div>
<p>プラグインがインストール済みなら、py.test が自動的に検出してそのプラグインを組み込みます。プラグインを有効化する必要はありません。既知のプラグイン一覧を紹介します:</p>
<ul class="simple">
<li><a class="reference external" href="http://pypi.python.org/pypi/pytest-capturelog">pytest-capturelog</a>: logging モジュールからのメッセージに関するアサートやキャプチャ</li>
</ul>
<ul class="simple">
<li><a class="reference external" href="http://pypi.python.org/pypi/pytest-xdist">pytest-xdist</a>: CPU やリモートホストを使った分散テスト、 <a class="reference internal" href="xdist.html#xdist"><em>xdist: pytest の分散テストプラグイン</em></a> を参照</li>
</ul>
<ul class="simple">
<li><a class="reference external" href="http://pypi.python.org/pypi/pytest-cov">pytest-cov</a>: 分散テストでの互換性やカバレッジレポート</li>
</ul>
<ul class="simple">
<li><a class="reference external" href="http://pypi.python.org/pypi/pytest-pep8">pytest-pep8</a>: <tt class="docutils literal"><span class="pre">--pep8</span></tt> オプションを使った PEP8 規約チェック</li>
</ul>
<ul class="simple">
<li><a class="reference external" href="http://pypi.python.org/pypi/oejskit">oejskit</a>: 実際のブラウザーで javascript の unittests を実行するプラグイン (<strong>バージョン 0.8.9 は pytest-2.0 では互換性がありません</strong> )</li>
</ul>
<p><a class="reference external" href="http://pypi.python.org/pypi?%3Aaction=search&amp;term=pytest-&amp;submit=search">&#8220;pytest-&#8221; で pypi.python.org を検索</a> すると、もっとプラグインが見つかるでしょう。</p>
</div>
<div class="section" id="id4">
<h2>サンプルによるプラグインの記述<a class="headerlink" href="#id4" title="このヘッドラインへのパーマリンク">¶</a></h2>
<p>自分でプラグインを作成したいなら、たくさんある実際のプラグインをコピーしてから始めると良いです:</p>
<ul class="simple">
<li>カスタムコレクションのサンプルプラグイン: <a class="reference internal" href="example/nonpython.html#yaml-plugin"><em>yaml プラグイン</em></a></li>
<li>py.test の独自機能を構成する約20個の <a class="reference internal" href="#builtin-plugins"><em>組み込みプラグイン</em></a></li>
<li>追加機能を提供する約10個の <a class="reference internal" href="#external-plugins"><em>外部プラグイン</em></a></li>
</ul>
<p>これらの全プラグインは、機能を追加/拡張するためにドキュメント付きの <a class="reference internal" href="#well-specified-hooks"><em>よく練られたフック</em></a> を実装します。</p>
</div>
<div class="section" id="setuptools-entry-points">
<span id="id5"></span><h2>独自プラグインを他からインストール可能にする<a class="headerlink" href="#setuptools-entry-points" title="このヘッドラインへのパーマリンク">¶</a></h2>
<p>自分で作成したプラグインを外部から利用できるようにしたいなら、 <tt class="docutils literal"><span class="pre">py.test</span></tt> がプラグインモジュールを見つけられるように、ディストリビューションのいわゆるエントリーポイントを定義します。エントリーポイントは <a class="reference external" href="http://pypi.python.org/pypi/setuptools">setuptools</a> または <a class="reference external" href="http://pypi.python.org/pypi/distribute">distribute</a> が提供する機能です。py.test は、プラグインを検出するために <tt class="docutils literal"><span class="pre">pytest11</span></tt> というエントリーポイントを調べます。このように setuptools/distribute の setup 処理でエントリーポイントを定義することにより、自分のプラグインを利用できます。</p>
<div class="highlight-python"><div class="highlight"><pre><span class="c"># サンプルの ./setup.py ファイル</span>
<span class="kn">from</span> <span class="nn">setuptools</span> <span class="kn">import</span> <span class="n">setup</span>

<span class="n">setup</span><span class="p">(</span>
    <span class="n">name</span><span class="o">=</span><span class="s">&quot;myproject&quot;</span><span class="p">,</span>
    <span class="n">packages</span> <span class="o">=</span> <span class="p">[</span><span class="s">&#39;myproject&#39;</span><span class="p">]</span>

    <span class="c"># 次のように記述して py.test からプラグインを利用可能にする</span>
    <span class="n">entry_points</span> <span class="o">=</span> <span class="p">{</span>
        <span class="s">&#39;pytest11&#39;</span><span class="p">:</span> <span class="p">[</span>
            <span class="s">&#39;name_of_plugin = myproject.pluginmodule&#39;</span><span class="p">,</span>
        <span class="p">]</span>
    <span class="p">},</span>
<span class="p">)</span>
</pre></div>
</div>
<p>パッケージがこの方法でインストールされる場合、py.test は <a class="reference internal" href="#well-specified-hooks"><em>よく練られたフック</em></a> を定義するプラグインとして <tt class="docutils literal"><span class="pre">myproject.pluginmodule</span></tt> を読み込みます。</p>
</div>
<div class="section" id="id6">
<h2>ツール起動時のプラグイン検出順序<a class="headerlink" href="#id6" title="このヘッドラインへのパーマリンク">¶</a></h2>
<p>py.test は、次の方法でツール起動時にプラグインモジュールを読み込みます。</p>
<ul class="simple">
<li>全ての組み込みプラグインを読み込む。</li>
</ul>
<ul class="simple">
<li><a class="reference internal" href="#setuptools-entry-points"><em>setuptools のエントリーポイント</em></a> から登録された全てのプラグインを読み込む。</li>
</ul>
<ul class="simple">
<li>コマンドラインの <tt class="docutils literal"><span class="pre">-p</span> <span class="pre">name</span></tt> オプションを事前に調べ、実際にコマンドラインの引数解析を行う前に指定したプラグインを読み込む。</li>
</ul>
<ul class="simple">
<li>コマンドラインの実行で推定される全ての <tt class="file docutils literal"><span class="pre">conftest.py</span></tt> ファイルを読み込む (テストファイルと全ての <em>親</em> ディレクトリ) 。 <em>サブ</em> ディレクトリからの <tt class="docutils literal"><span class="pre">conftest.py</span></tt> ファイルは、デフォルトでは、ツールの起動時に読み込まれないことに注意してください。</li>
</ul>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">conftest.py</span></tt> ファイルの <tt class="docutils literal"><span class="pre">pytest_plugins</span></tt> 変数で指定された全てのプラグインを再帰的に読み込む</li>
</ul>
</div>
<div class="section" id="id7">
<h2>テストモジュールまたは conftest ファイルのプラグインの要求と読み込み<a class="headerlink" href="#id7" title="このヘッドラインへのパーマリンク">¶</a></h2>
<p>テストモジュール、または conftest ファイル内でプラグインを要求できます:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">pytest_plugins</span> <span class="o">=</span> <span class="s">&quot;name1&quot;</span><span class="p">,</span> <span class="s">&quot;name2&quot;</span><span class="p">,</span>
</pre></div>
</div>
<p>テストモジュール、または conftest プラグインが読み込まれるとき、指定したプラグインも同様に読み込まれます。さらに次のようにドット区切りのパスも使えます:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">pytest_plugins</span> <span class="o">=</span> <span class="s">&quot;myapp.testsupport.myplugin&quot;</span>
</pre></div>
</div>
<p>これは py.test プラグインとして指定したモジュールをインポートします。</p>
</div>
<div class="section" id="id8">
<h2>プラグイン名で別のプラグインへアクセス<a class="headerlink" href="#id8" title="このヘッドラインへのパーマリンク">¶</a></h2>
<p>あるプラグインと別のプラグインのコードを協調させたいなら、次のようにプラグインマネージャーを使ってリファレンスを取得できます:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">plugin</span> <span class="o">=</span> <span class="n">config</span><span class="o">.</span><span class="n">pluginmanager</span><span class="o">.</span><span class="n">getplugin</span><span class="p">(</span><span class="s">&quot;name_of_plugin&quot;</span><span class="p">)</span>
</pre></div>
</div>
<p>既存のプラグイン名を調べたい場合は <tt class="docutils literal"><span class="pre">--traceconfig</span></tt> オプションを使ってください。</p>
</div>
<div class="section" id="findpluginname">
<span id="id9"></span><h2>有効なプラグインの検出<a class="headerlink" href="#findpluginname" title="このヘッドラインへのパーマリンク">¶</a></h2>
<p>自分の環境で有効なプラグインを調べたいなら、次のように実行してください:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">py</span><span class="o">.</span><span class="n">test</span> <span class="o">--</span><span class="n">traceconfig</span>
</pre></div>
</div>
<p>有効なプラグインとその名前を表示する拡張テストヘッダーを取得します。 <a class="reference internal" href="#id1"><em>conftest.py</em></a> が読み込まれるときにそのローカルプラグインも表示します。</p>
</div>
<div class="section" id="cmdunregister">
<span id="id10"></span><h2>名前からプラグインの無効化や登録解除<a class="headerlink" href="#cmdunregister" title="このヘッドラインへのパーマリンク">¶</a></h2>
<p>プラグインを読み込ませない、または登録を解除できます:</p>
<div class="highlight-python"><pre>py.test -p no:NAME</pre>
</div>
<p>このオプションは、有効化/読み込もうとするプラグインが既に存在するものとして扱います。プラグイン名を取得する方法は <a class="reference internal" href="#findpluginname"><em>有効なプラグインの検出</em></a> を参照してください。</p>
</div>
</div>
<div class="section" id="py-test">
<span id="builtin-plugins"></span><h1>py.test のデフォルトのプラグインリファレンス<a class="headerlink" href="#py-test" title="このヘッドラインへのパーマリンク">¶</a></h1>
<p>次のプラグインのソースコードが <a class="reference external" href="http://bitbucket.org/hpk42/pytest/">pytest リポジトリ</a> に含まれています。</p>
<table border="1" class="longtable docutils">
<colgroup>
<col width="10%" />
<col width="90%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><tt class="xref py py-obj docutils literal"><span class="pre">_pytest.assertion</span></tt></td>
<td>support for presenting detailed information in failing assertions.</td>
</tr>
<tr class="row-even"><td><tt class="xref py py-obj docutils literal"><span class="pre">_pytest.capture</span></tt></td>
<td>per-test stdout/stderr capturing mechanisms, <tt class="docutils literal"><span class="pre">capsys</span></tt> and <tt class="docutils literal"><span class="pre">capfd</span></tt> function arguments.</td>
</tr>
<tr class="row-odd"><td><tt class="xref py py-obj docutils literal"><span class="pre">_pytest.config</span></tt></td>
<td>command line options, ini-file and conftest.py processing.</td>
</tr>
<tr class="row-even"><td><tt class="xref py py-obj docutils literal"><span class="pre">_pytest.doctest</span></tt></td>
<td>discover and run doctests in modules and test files.</td>
</tr>
<tr class="row-odd"><td><tt class="xref py py-obj docutils literal"><span class="pre">_pytest.genscript</span></tt></td>
<td>generate a single-file self-contained version of py.test</td>
</tr>
<tr class="row-even"><td><tt class="xref py py-obj docutils literal"><span class="pre">_pytest.helpconfig</span></tt></td>
<td>version info, help messages, tracing configuration.</td>
</tr>
<tr class="row-odd"><td><tt class="xref py py-obj docutils literal"><span class="pre">_pytest.junitxml</span></tt></td>
<td>report test results in JUnit-XML format, for use with Hudson and build integration servers.</td>
</tr>
<tr class="row-even"><td><tt class="xref py py-obj docutils literal"><span class="pre">_pytest.mark</span></tt></td>
<td>generic mechanism for marking and selecting python functions.</td>
</tr>
<tr class="row-odd"><td><tt class="xref py py-obj docutils literal"><span class="pre">_pytest.monkeypatch</span></tt></td>
<td>monkeypatching and mocking functionality.</td>
</tr>
<tr class="row-even"><td><tt class="xref py py-obj docutils literal"><span class="pre">_pytest.nose</span></tt></td>
<td>run test suites written for nose.</td>
</tr>
<tr class="row-odd"><td><tt class="xref py py-obj docutils literal"><span class="pre">_pytest.pastebin</span></tt></td>
<td>submit failure or test session information to a pastebin service.</td>
</tr>
<tr class="row-even"><td><tt class="xref py py-obj docutils literal"><span class="pre">_pytest.pdb</span></tt></td>
<td>interactive debugging with PDB, the Python Debugger.</td>
</tr>
<tr class="row-odd"><td><tt class="xref py py-obj docutils literal"><span class="pre">_pytest.pytester</span></tt></td>
<td>(disabled by default) support for testing py.test and py.test plugins.</td>
</tr>
<tr class="row-even"><td><tt class="xref py py-obj docutils literal"><span class="pre">_pytest.python</span></tt></td>
<td>Python test discovery, setup and run of test functions.</td>
</tr>
<tr class="row-odd"><td><tt class="xref py py-obj docutils literal"><span class="pre">_pytest.recwarn</span></tt></td>
<td>recording warnings during test function execution.</td>
</tr>
<tr class="row-even"><td><tt class="xref py py-obj docutils literal"><span class="pre">_pytest.resultlog</span></tt></td>
<td>log machine-parseable test session result information in a plain</td>
</tr>
<tr class="row-odd"><td><tt class="xref py py-obj docutils literal"><span class="pre">_pytest.runner</span></tt></td>
<td>basic collect and runtest protocol implementations</td>
</tr>
<tr class="row-even"><td><tt class="xref py py-obj docutils literal"><span class="pre">_pytest.main</span></tt></td>
<td>core implementation of testing process: init, session, runtest loop.</td>
</tr>
<tr class="row-odd"><td><tt class="xref py py-obj docutils literal"><span class="pre">_pytest.skipping</span></tt></td>
<td>support for skip/xfail functions and markers.</td>
</tr>
<tr class="row-even"><td><tt class="xref py py-obj docutils literal"><span class="pre">_pytest.terminal</span></tt></td>
<td>terminal reporting of the full testing process.</td>
</tr>
<tr class="row-odd"><td><tt class="xref py py-obj docutils literal"><span class="pre">_pytest.tmpdir</span></tt></td>
<td>support for providing temporary directories to test functions.</td>
</tr>
<tr class="row-even"><td><tt class="xref py py-obj docutils literal"><span class="pre">_pytest.unittest</span></tt></td>
<td>discovery and running of std-library &#8220;unittest&#8221; style tests.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="well-specified-hooks">
<span id="id11"></span><h1>py.test のフックリファレンス<a class="headerlink" href="#well-specified-hooks" title="このヘッドラインへのパーマリンク">¶</a></h1>
<div class="section" id="id12">
<h2>フックの仕様と検証<a class="headerlink" href="#id12" title="このヘッドラインへのパーマリンク">¶</a></h2>
<p>py.test は、初期化、テスト実行、レポートを実装するフック関数を呼び出します。py.test がプラグインを読み込むとき、各フック関数名はその対応するフック仕様を確認します。各フック関数名とその引数の名前は、フック仕様に一致する必要があります。但し、フック関数を単に指定しないことにより <em>少ない</em> パラメーターは許容します。引数の名前やフック名そのものを誤入力した場合、利用できる引数を表示するエラーが表示されます。</p>
</div>
<div class="section" id="id13">
<h2>初期化、コマンドライン、設定のフック<a class="headerlink" href="#id13" title="このヘッドラインへのパーマリンク">¶</a></h2>
<dl class="function">
<dt id="_pytest.hookspec.pytest_cmdline_preparse">
<tt class="descclassname">_pytest.hookspec.</tt><tt class="descname">pytest_cmdline_preparse</tt><big>(</big><em>config</em>, <em>args</em><big>)</big><a class="reference internal" href="_modules/_pytest/hookspec.html#pytest_cmdline_preparse"><span class="viewcode-link">[ソース]</span></a><a class="headerlink" href="#_pytest.hookspec.pytest_cmdline_preparse" title="この定義へのパーマリンク">¶</a></dt>
<dd><p>modify command line arguments before option parsing.</p>
</dd></dl>

<dl class="function">
<dt id="_pytest.hookspec.pytest_cmdline_parse">
<tt class="descclassname">_pytest.hookspec.</tt><tt class="descname">pytest_cmdline_parse</tt><big>(</big><em>pluginmanager</em>, <em>args</em><big>)</big><a class="reference internal" href="_modules/_pytest/hookspec.html#pytest_cmdline_parse"><span class="viewcode-link">[ソース]</span></a><a class="headerlink" href="#_pytest.hookspec.pytest_cmdline_parse" title="この定義へのパーマリンク">¶</a></dt>
<dd><p>return initialized config object, parsing the specified args.</p>
</dd></dl>

<dl class="function">
<dt id="_pytest.hookspec.pytest_namespace">
<tt class="descclassname">_pytest.hookspec.</tt><tt class="descname">pytest_namespace</tt><big>(</big><big>)</big><a class="reference internal" href="_modules/_pytest/hookspec.html#pytest_namespace"><span class="viewcode-link">[ソース]</span></a><a class="headerlink" href="#_pytest.hookspec.pytest_namespace" title="この定義へのパーマリンク">¶</a></dt>
<dd><p>return dict of name-&gt;object to be made globally available in
the py.test/pytest namespace.  This hook is called before command
line options are parsed.</p>
</dd></dl>

<dl class="function">
<dt id="_pytest.hookspec.pytest_addoption">
<tt class="descclassname">_pytest.hookspec.</tt><tt class="descname">pytest_addoption</tt><big>(</big><em>parser</em><big>)</big><a class="reference internal" href="_modules/_pytest/hookspec.html#pytest_addoption"><span class="viewcode-link">[ソース]</span></a><a class="headerlink" href="#_pytest.hookspec.pytest_addoption" title="この定義へのパーマリンク">¶</a></dt>
<dd><p>register optparse-style options and ini-style config values.</p>
<p>This function must be implemented in a <em class="xref std std-ref">plugin</em> and is
called once at the beginning of a test run.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">パラメタ:</th><td class="field-body"><strong>parser</strong> &#8211; To add command line options, call
<a class="reference internal" href="#_pytest.config.Parser.addoption" title="_pytest.config.Parser.addoption"><tt class="xref py py-func docutils literal"><span class="pre">parser.addoption(...)</span></tt></a>.
To add ini-file values call <a class="reference internal" href="#_pytest.config.Parser.addini" title="_pytest.config.Parser.addini"><tt class="xref py py-func docutils literal"><span class="pre">parser.addini(...)</span></tt></a>.</td>
</tr>
</tbody>
</table>
<p>Options can later be accessed through the
<a class="reference internal" href="#_pytest.config.Config" title="_pytest.config.Config"><tt class="xref py py-class docutils literal"><span class="pre">config</span></tt></a> object, respectively:</p>
<ul class="simple">
<li><a class="reference internal" href="#_pytest.config.Config.getoption" title="_pytest.config.Config.getoption"><tt class="xref py py-func docutils literal"><span class="pre">config.getoption(name)</span></tt></a> to
retrieve the value of a command line option.</li>
<li><a class="reference internal" href="#_pytest.config.Config.getini" title="_pytest.config.Config.getini"><tt class="xref py py-func docutils literal"><span class="pre">config.getini(name)</span></tt></a> to retrieve
a value read from an ini-style file.</li>
</ul>
<p>The config object is passed around on many internal objects via the <tt class="docutils literal"><span class="pre">.config</span></tt>
attribute or can be retrieved as the <tt class="docutils literal"><span class="pre">pytestconfig</span></tt> fixture or accessed
via (deprecated) <tt class="docutils literal"><span class="pre">pytest.config</span></tt>.</p>
</dd></dl>

<dl class="function">
<dt id="_pytest.hookspec.pytest_cmdline_main">
<tt class="descclassname">_pytest.hookspec.</tt><tt class="descname">pytest_cmdline_main</tt><big>(</big><em>config</em><big>)</big><a class="reference internal" href="_modules/_pytest/hookspec.html#pytest_cmdline_main"><span class="viewcode-link">[ソース]</span></a><a class="headerlink" href="#_pytest.hookspec.pytest_cmdline_main" title="この定義へのパーマリンク">¶</a></dt>
<dd><p>called for performing the main command line action. The default
implementation will invoke the configure hooks and runtest_mainloop.</p>
</dd></dl>

<dl class="function">
<dt id="_pytest.hookspec.pytest_configure">
<tt class="descclassname">_pytest.hookspec.</tt><tt class="descname">pytest_configure</tt><big>(</big><em>config</em><big>)</big><a class="reference internal" href="_modules/_pytest/hookspec.html#pytest_configure"><span class="viewcode-link">[ソース]</span></a><a class="headerlink" href="#_pytest.hookspec.pytest_configure" title="この定義へのパーマリンク">¶</a></dt>
<dd><p>called after command line options have been parsed
and all plugins and initial conftest files been loaded.</p>
</dd></dl>

<dl class="function">
<dt id="_pytest.hookspec.pytest_unconfigure">
<tt class="descclassname">_pytest.hookspec.</tt><tt class="descname">pytest_unconfigure</tt><big>(</big><em>config</em><big>)</big><a class="reference internal" href="_modules/_pytest/hookspec.html#pytest_unconfigure"><span class="viewcode-link">[ソース]</span></a><a class="headerlink" href="#_pytest.hookspec.pytest_unconfigure" title="この定義へのパーマリンク">¶</a></dt>
<dd><p>called before test process is exited.</p>
</dd></dl>

</div>
<div class="section" id="runtest">
<h2>汎用的な &#8220;runtest&#8221; フック<a class="headerlink" href="#runtest" title="このヘッドラインへのパーマリンク">¶</a></h2>
<p>フックに関連する全ての runtest は <tt class="xref py py-class docutils literal"><span class="pre">pytest.Item</span></tt> オブジェクトを受け取ります。</p>
<dl class="function">
<dt id="_pytest.hookspec.pytest_runtest_protocol">
<tt class="descclassname">_pytest.hookspec.</tt><tt class="descname">pytest_runtest_protocol</tt><big>(</big><em>item</em>, <em>nextitem</em><big>)</big><a class="reference internal" href="_modules/_pytest/hookspec.html#pytest_runtest_protocol"><span class="viewcode-link">[ソース]</span></a><a class="headerlink" href="#_pytest.hookspec.pytest_runtest_protocol" title="この定義へのパーマリンク">¶</a></dt>
<dd><p>implements the runtest_setup/call/teardown protocol for
the given test item, including capturing exceptions and calling
reporting hooks.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">パラメタ:</th><td class="field-body"><ul class="first simple">
<li><strong>item</strong> &#8211; test item for which the runtest protocol is performed.</li>
<li><strong>nexitem</strong> &#8211; the scheduled-to-be-next test item (or None if this
is the end my friend).  This argument is passed on to
<a class="reference internal" href="#_pytest.hookspec.pytest_runtest_teardown" title="_pytest.hookspec.pytest_runtest_teardown"><tt class="xref py py-func docutils literal"><span class="pre">pytest_runtest_teardown()</span></tt></a>.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Return boolean:</th><td class="field-body"><p class="first last">True if no further hook implementations should be invoked.</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="function">
<dt id="_pytest.hookspec.pytest_runtest_setup">
<tt class="descclassname">_pytest.hookspec.</tt><tt class="descname">pytest_runtest_setup</tt><big>(</big><em>item</em><big>)</big><a class="reference internal" href="_modules/_pytest/hookspec.html#pytest_runtest_setup"><span class="viewcode-link">[ソース]</span></a><a class="headerlink" href="#_pytest.hookspec.pytest_runtest_setup" title="この定義へのパーマリンク">¶</a></dt>
<dd><p>called before <tt class="docutils literal"><span class="pre">pytest_runtest_call(item)</span></tt>.</p>
</dd></dl>

<dl class="function">
<dt id="_pytest.hookspec.pytest_runtest_call">
<tt class="descclassname">_pytest.hookspec.</tt><tt class="descname">pytest_runtest_call</tt><big>(</big><em>item</em><big>)</big><a class="reference internal" href="_modules/_pytest/hookspec.html#pytest_runtest_call"><span class="viewcode-link">[ソース]</span></a><a class="headerlink" href="#_pytest.hookspec.pytest_runtest_call" title="この定義へのパーマリンク">¶</a></dt>
<dd><p>called to execute the test <tt class="docutils literal"><span class="pre">item</span></tt>.</p>
</dd></dl>

<dl class="function">
<dt id="_pytest.hookspec.pytest_runtest_teardown">
<tt class="descclassname">_pytest.hookspec.</tt><tt class="descname">pytest_runtest_teardown</tt><big>(</big><em>item</em>, <em>nextitem</em><big>)</big><a class="reference internal" href="_modules/_pytest/hookspec.html#pytest_runtest_teardown"><span class="viewcode-link">[ソース]</span></a><a class="headerlink" href="#_pytest.hookspec.pytest_runtest_teardown" title="この定義へのパーマリンク">¶</a></dt>
<dd><p>called after <tt class="docutils literal"><span class="pre">pytest_runtest_call</span></tt>.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">パラメタ:</th><td class="field-body"><strong>nexitem</strong> &#8211; the scheduled-to-be-next test item (None if no further
test item is scheduled).  This argument can be used to
perform exact teardowns, i.e. calling just enough finalizers
so that nextitem only needs to call setup-functions.</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="function">
<dt id="_pytest.hookspec.pytest_runtest_makereport">
<tt class="descclassname">_pytest.hookspec.</tt><tt class="descname">pytest_runtest_makereport</tt><big>(</big><em>item</em>, <em>call</em><big>)</big><a class="reference internal" href="_modules/_pytest/hookspec.html#pytest_runtest_makereport"><span class="viewcode-link">[ソース]</span></a><a class="headerlink" href="#_pytest.hookspec.pytest_runtest_makereport" title="この定義へのパーマリンク">¶</a></dt>
<dd><p>return a <a class="reference internal" href="#_pytest.runner.TestReport" title="_pytest.runner.TestReport"><tt class="xref py py-class docutils literal"><span class="pre">_pytest.runner.TestReport</span></tt></a> object
for the given <tt class="xref py py-class docutils literal"><span class="pre">pytest.Item</span></tt> and
<a class="reference internal" href="#_pytest.runner.CallInfo" title="_pytest.runner.CallInfo"><tt class="xref py py-class docutils literal"><span class="pre">_pytest.runner.CallInfo</span></tt></a>.</p>
</dd></dl>

<p>より深く理解するには <tt class="xref py py-mod docutils literal"><span class="pre">_pytest.runner</span></tt> の実際のフックのデフォルト実装を調べることになるかもしれません。さらに、テストが失敗したときにそのまま対話式のデバッガーに入る、その入出力のキャプチャや <tt class="xref py py-mod docutils literal"><span class="pre">_pytest.capture</span></tt> と相互にやり取りする <tt class="xref py py-mod docutils literal"><span class="pre">_pytest.pdb</span></tt> もきっと見たくなるでしょう。</p>
<p>実際にレポートを行う <tt class="xref py py-mod docutils literal"><span class="pre">_pytest.terminal</span></tt> は、テスト実行に関する情報を表示するためにレポートフックを使います。</p>
</div>
<div class="section" id="id14">
<h2>コレクションのフック<a class="headerlink" href="#id14" title="このヘッドラインへのパーマリンク">¶</a></h2>
<p>py.test はファイルとディレクトリを探索するために次のフックを呼び出します:</p>
<dl class="function">
<dt id="_pytest.hookspec.pytest_ignore_collect">
<tt class="descclassname">_pytest.hookspec.</tt><tt class="descname">pytest_ignore_collect</tt><big>(</big><em>path</em>, <em>config</em><big>)</big><a class="reference internal" href="_modules/_pytest/hookspec.html#pytest_ignore_collect"><span class="viewcode-link">[ソース]</span></a><a class="headerlink" href="#_pytest.hookspec.pytest_ignore_collect" title="この定義へのパーマリンク">¶</a></dt>
<dd><p>return True to prevent considering this path for collection.
This hook is consulted for all files and directories prior to calling
more specific hooks.</p>
</dd></dl>

<dl class="function">
<dt id="_pytest.hookspec.pytest_collect_directory">
<tt class="descclassname">_pytest.hookspec.</tt><tt class="descname">pytest_collect_directory</tt><big>(</big><em>path</em>, <em>parent</em><big>)</big><a class="reference internal" href="_modules/_pytest/hookspec.html#pytest_collect_directory"><span class="viewcode-link">[ソース]</span></a><a class="headerlink" href="#_pytest.hookspec.pytest_collect_directory" title="この定義へのパーマリンク">¶</a></dt>
<dd><p>called before traversing a directory for collection files.</p>
</dd></dl>

<dl class="function">
<dt id="_pytest.hookspec.pytest_collect_file">
<tt class="descclassname">_pytest.hookspec.</tt><tt class="descname">pytest_collect_file</tt><big>(</big><em>path</em>, <em>parent</em><big>)</big><a class="reference internal" href="_modules/_pytest/hookspec.html#pytest_collect_file"><span class="viewcode-link">[ソース]</span></a><a class="headerlink" href="#_pytest.hookspec.pytest_collect_file" title="この定義へのパーマリンク">¶</a></dt>
<dd><p>return collection Node or None for the given path. Any new node
needs to have the specified <tt class="docutils literal"><span class="pre">parent</span></tt> as a parent.</p>
</dd></dl>

<p>Python モジュール内のオブジェクトのコレクションに影響を与えるには、次のフックが使えます:</p>
<dl class="function">
<dt id="_pytest.hookspec.pytest_pycollect_makeitem">
<tt class="descclassname">_pytest.hookspec.</tt><tt class="descname">pytest_pycollect_makeitem</tt><big>(</big><em>collector</em>, <em>name</em>, <em>obj</em><big>)</big><a class="reference internal" href="_modules/_pytest/hookspec.html#pytest_pycollect_makeitem"><span class="viewcode-link">[ソース]</span></a><a class="headerlink" href="#_pytest.hookspec.pytest_pycollect_makeitem" title="この定義へのパーマリンク">¶</a></dt>
<dd><p>return custom item/collector for a python object in a module, or None.</p>
</dd></dl>

</div>
<div class="section" id="id15">
<h2>レポートフック<a class="headerlink" href="#id15" title="このヘッドラインへのパーマリンク">¶</a></h2>
<p>レポートフックに関連するセッション:</p>
<dl class="function">
<dt id="_pytest.hookspec.pytest_collectstart">
<tt class="descclassname">_pytest.hookspec.</tt><tt class="descname">pytest_collectstart</tt><big>(</big><em>collector</em><big>)</big><a class="reference internal" href="_modules/_pytest/hookspec.html#pytest_collectstart"><span class="viewcode-link">[ソース]</span></a><a class="headerlink" href="#_pytest.hookspec.pytest_collectstart" title="この定義へのパーマリンク">¶</a></dt>
<dd><p>collector starts collecting.</p>
</dd></dl>

<dl class="function">
<dt id="_pytest.hookspec.pytest_itemcollected">
<tt class="descclassname">_pytest.hookspec.</tt><tt class="descname">pytest_itemcollected</tt><big>(</big><em>item</em><big>)</big><a class="reference internal" href="_modules/_pytest/hookspec.html#pytest_itemcollected"><span class="viewcode-link">[ソース]</span></a><a class="headerlink" href="#_pytest.hookspec.pytest_itemcollected" title="この定義へのパーマリンク">¶</a></dt>
<dd><p>we just collected a test item.</p>
</dd></dl>

<dl class="function">
<dt id="_pytest.hookspec.pytest_collectreport">
<tt class="descclassname">_pytest.hookspec.</tt><tt class="descname">pytest_collectreport</tt><big>(</big><em>report</em><big>)</big><a class="reference internal" href="_modules/_pytest/hookspec.html#pytest_collectreport"><span class="viewcode-link">[ソース]</span></a><a class="headerlink" href="#_pytest.hookspec.pytest_collectreport" title="この定義へのパーマリンク">¶</a></dt>
<dd><p>collector finished collecting.</p>
</dd></dl>

<dl class="function">
<dt id="_pytest.hookspec.pytest_deselected">
<tt class="descclassname">_pytest.hookspec.</tt><tt class="descname">pytest_deselected</tt><big>(</big><em>items</em><big>)</big><a class="reference internal" href="_modules/_pytest/hookspec.html#pytest_deselected"><span class="viewcode-link">[ソース]</span></a><a class="headerlink" href="#_pytest.hookspec.pytest_deselected" title="この定義へのパーマリンク">¶</a></dt>
<dd><p>called for test items deselected by keyword.</p>
</dd></dl>

<p>そして、テストの実行に関する中央のフックです:</p>
<dl class="function">
<dt id="_pytest.hookspec.pytest_runtest_logreport">
<tt class="descclassname">_pytest.hookspec.</tt><tt class="descname">pytest_runtest_logreport</tt><big>(</big><em>report</em><big>)</big><a class="reference internal" href="_modules/_pytest/hookspec.html#pytest_runtest_logreport"><span class="viewcode-link">[ソース]</span></a><a class="headerlink" href="#_pytest.hookspec.pytest_runtest_logreport" title="この定義へのパーマリンク">¶</a></dt>
<dd><p>process a test setup/call/teardown report relating to
the respective phase of executing a test.</p>
</dd></dl>

</div>
</div>
<div class="section" id="id16">
<h1>フックで実行される重要なオブジェクトのリファレンス<a class="headerlink" href="#id16" title="このヘッドラインへのパーマリンク">¶</a></h1>
<dl class="class">
<dt id="_pytest.config.Config">
<em class="property">class </em><tt class="descclassname">_pytest.config.</tt><tt class="descname">Config</tt><big>(</big><em>pluginmanager=None</em><big>)</big><a class="reference internal" href="_modules/_pytest/config.html#Config"><span class="viewcode-link">[ソース]</span></a><a class="headerlink" href="#_pytest.config.Config" title="この定義へのパーマリンク">¶</a></dt>
<dd><p>access to configuration values, pluginmanager and plugin hooks.</p>
<dl class="method">
<dt id="_pytest.config.Config.addinivalue_line">
<tt class="descname">addinivalue_line</tt><big>(</big><em>name</em>, <em>line</em><big>)</big><a class="reference internal" href="_modules/_pytest/config.html#Config.addinivalue_line"><span class="viewcode-link">[ソース]</span></a><a class="headerlink" href="#_pytest.config.Config.addinivalue_line" title="この定義へのパーマリンク">¶</a></dt>
<dd><p>add a line to an ini-file option. The option must have been
declared but might not yet be set in which case the line becomes the
the first line in its value.</p>
</dd></dl>

<dl class="classmethod">
<dt id="_pytest.config.Config.fromdictargs">
<em class="property">classmethod </em><tt class="descname">fromdictargs</tt><big>(</big><em>option_dict</em>, <em>args</em><big>)</big><a class="reference internal" href="_modules/_pytest/config.html#Config.fromdictargs"><span class="viewcode-link">[ソース]</span></a><a class="headerlink" href="#_pytest.config.Config.fromdictargs" title="この定義へのパーマリンク">¶</a></dt>
<dd><p>constructor useable for subprocesses.</p>
</dd></dl>

<dl class="method">
<dt id="_pytest.config.Config.getini">
<tt class="descname">getini</tt><big>(</big><em>name</em><big>)</big><a class="reference internal" href="_modules/_pytest/config.html#Config.getini"><span class="viewcode-link">[ソース]</span></a><a class="headerlink" href="#_pytest.config.Config.getini" title="この定義へのパーマリンク">¶</a></dt>
<dd><p>return configuration value from an <em class="xref std std-ref">ini file</em>. If the
specified name hasn&#8217;t been registered through a prior
<tt class="xref py py-func docutils literal"><span class="pre">parser.addini</span></tt>
call (usually from a plugin), a ValueError is raised.</p>
</dd></dl>

<dl class="method">
<dt id="_pytest.config.Config.getoption">
<tt class="descname">getoption</tt><big>(</big><em>name</em><big>)</big><a class="reference internal" href="_modules/_pytest/config.html#Config.getoption"><span class="viewcode-link">[ソース]</span></a><a class="headerlink" href="#_pytest.config.Config.getoption" title="この定義へのパーマリンク">¶</a></dt>
<dd><p>return command line option value.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">パラメタ:</th><td class="field-body"><strong>name</strong> &#8211; name of the option.  You may also specify
the literal <tt class="docutils literal"><span class="pre">--OPT</span></tt> option instead of the &#8220;dest&#8221; option name.</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="_pytest.config.Config.getvalue">
<tt class="descname">getvalue</tt><big>(</big><em>name</em>, <em>path=None</em><big>)</big><a class="reference internal" href="_modules/_pytest/config.html#Config.getvalue"><span class="viewcode-link">[ソース]</span></a><a class="headerlink" href="#_pytest.config.Config.getvalue" title="この定義へのパーマリンク">¶</a></dt>
<dd><p>return command line option value.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">パラメタ:</th><td class="field-body"><strong>name</strong> &#8211; name of the command line option</td>
</tr>
</tbody>
</table>
<p>(deprecated) if we can&#8217;t find the option also lookup
the name in a matching conftest file.</p>
</dd></dl>

<dl class="method">
<dt id="_pytest.config.Config.getvalueorskip">
<tt class="descname">getvalueorskip</tt><big>(</big><em>name</em>, <em>path=None</em><big>)</big><a class="reference internal" href="_modules/_pytest/config.html#Config.getvalueorskip"><span class="viewcode-link">[ソース]</span></a><a class="headerlink" href="#_pytest.config.Config.getvalueorskip" title="この定義へのパーマリンク">¶</a></dt>
<dd><p>(deprecated) return getvalue(name) or call
py.test.skip if no value exists.</p>
</dd></dl>

<dl class="attribute">
<dt id="_pytest.config.Config.option">
<tt class="descname">option</tt><em class="property"> = None</em><a class="headerlink" href="#_pytest.config.Config.option" title="この定義へのパーマリンク">¶</a></dt>
<dd><p>access to command line option as attributes.
(deprecated), use <a class="reference internal" href="#_pytest.config.Config.getoption" title="_pytest.config.Config.getoption"><tt class="xref py py-func docutils literal"><span class="pre">getoption()</span></tt></a> instead</p>
</dd></dl>

<dl class="attribute">
<dt id="_pytest.config.Config.pluginmanager">
<tt class="descname">pluginmanager</tt><em class="property"> = None</em><a class="headerlink" href="#_pytest.config.Config.pluginmanager" title="この定義へのパーマリンク">¶</a></dt>
<dd><p>a pluginmanager instance</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="_pytest.config.Parser">
<em class="property">class </em><tt class="descclassname">_pytest.config.</tt><tt class="descname">Parser</tt><big>(</big><em>usage=None</em>, <em>processopt=None</em><big>)</big><a class="reference internal" href="_modules/_pytest/config.html#Parser"><span class="viewcode-link">[ソース]</span></a><a class="headerlink" href="#_pytest.config.Parser" title="この定義へのパーマリンク">¶</a></dt>
<dd><p>Parser for command line arguments and ini-file values.</p>
<dl class="method">
<dt id="_pytest.config.Parser.addini">
<tt class="descname">addini</tt><big>(</big><em>name</em>, <em>help</em>, <em>type=None</em>, <em>default=None</em><big>)</big><a class="reference internal" href="_modules/_pytest/config.html#Parser.addini"><span class="viewcode-link">[ソース]</span></a><a class="headerlink" href="#_pytest.config.Parser.addini" title="この定義へのパーマリンク">¶</a></dt>
<dd><p>register an ini-file option.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Name :</th><td class="field-body">name of the ini-variable</td>
</tr>
<tr class="field-even field"><th class="field-name">Type :</th><td class="field-body">type of the variable, can be <tt class="docutils literal"><span class="pre">pathlist</span></tt>, <tt class="docutils literal"><span class="pre">args</span></tt> or <tt class="docutils literal"><span class="pre">linelist</span></tt>.</td>
</tr>
<tr class="field-odd field"><th class="field-name">Default :</th><td class="field-body">default value if no ini-file option exists but is queried.</td>
</tr>
</tbody>
</table>
<p>The value of ini-variables can be retrieved via a call to
<a class="reference internal" href="#_pytest.config.Config.getini" title="_pytest.config.Config.getini"><tt class="xref py py-func docutils literal"><span class="pre">config.getini(name)</span></tt></a>.</p>
</dd></dl>

<dl class="method">
<dt id="_pytest.config.Parser.addoption">
<tt class="descname">addoption</tt><big>(</big><em>*opts</em>, <em>**attrs</em><big>)</big><a class="reference internal" href="_modules/_pytest/config.html#Parser.addoption"><span class="viewcode-link">[ソース]</span></a><a class="headerlink" href="#_pytest.config.Parser.addoption" title="この定義へのパーマリンク">¶</a></dt>
<dd><p>register a command line option.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Opts :</th><td class="field-body">option names, can be short or long options.</td>
</tr>
<tr class="field-even field"><th class="field-name">Attrs :</th><td class="field-body">same attributes which the <tt class="docutils literal"><span class="pre">add_option()</span></tt> function of the
<a class="reference external" href="http://docs.python.org/library/optparse.html#module-optparse">optparse library</a>
accepts.</td>
</tr>
</tbody>
</table>
<p>After command line parsing options are available on the pytest config
object via <tt class="docutils literal"><span class="pre">config.option.NAME</span></tt> where <tt class="docutils literal"><span class="pre">NAME</span></tt> is usually set
by passing a <tt class="docutils literal"><span class="pre">dest</span></tt> attribute, for example
<tt class="docutils literal"><span class="pre">addoption(&quot;--long&quot;,</span> <span class="pre">dest=&quot;NAME&quot;,</span> <span class="pre">...)</span></tt>.</p>
</dd></dl>

<dl class="method">
<dt id="_pytest.config.Parser.getgroup">
<tt class="descname">getgroup</tt><big>(</big><em>name</em>, <em>description=''</em>, <em>after=None</em><big>)</big><a class="reference internal" href="_modules/_pytest/config.html#Parser.getgroup"><span class="viewcode-link">[ソース]</span></a><a class="headerlink" href="#_pytest.config.Parser.getgroup" title="この定義へのパーマリンク">¶</a></dt>
<dd><p>get (or create) a named option Group.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Name :</th><td class="field-body">name of the option group.</td>
</tr>
<tr class="field-even field"><th class="field-name">Description :</th><td class="field-body">long description for &#8211;help output.</td>
</tr>
<tr class="field-odd field"><th class="field-name">After :</th><td class="field-body">name of other group, used for ordering &#8211;help output.</td>
</tr>
</tbody>
</table>
<p>The returned group object has an <tt class="docutils literal"><span class="pre">addoption</span></tt> method with the same
signature as <a class="reference internal" href="#_pytest.config.Parser.addoption" title="_pytest.config.Parser.addoption"><tt class="xref py py-func docutils literal"><span class="pre">parser.addoption</span></tt></a> but will be shown in the
respective group in the output of <tt class="docutils literal"><span class="pre">pytest.</span> <span class="pre">--help</span></tt>.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="_pytest.main.Node">
<em class="property">class </em><tt class="descclassname">_pytest.main.</tt><tt class="descname">Node</tt><big>(</big><em>name</em>, <em>parent</em><big>)</big><a class="reference internal" href="_modules/_pytest/main.html#Node"><span class="viewcode-link">[ソース]</span></a><a class="headerlink" href="#_pytest.main.Node" title="この定義へのパーマリンク">¶</a></dt>
<dd><p>base class for Collector and Item the test collection tree.
Collector subclasses have children, Items are terminal nodes.</p>
<dl class="attribute">
<dt id="_pytest.main.Node.config">
<tt class="descname">config</tt><em class="property"> = None</em><a class="headerlink" href="#_pytest.main.Node.config" title="この定義へのパーマリンク">¶</a></dt>
<dd><p>the pytest config object</p>
</dd></dl>

<dl class="attribute">
<dt id="_pytest.main.Node.fspath">
<tt class="descname">fspath</tt><em class="property"> = None</em><a class="headerlink" href="#_pytest.main.Node.fspath" title="この定義へのパーマリンク">¶</a></dt>
<dd><p>filesystem path where this node was collected from (can be None)</p>
</dd></dl>

<dl class="attribute">
<dt id="_pytest.main.Node.ihook">
<tt class="descname">ihook</tt><a class="reference internal" href="_modules/_pytest/main.html#Node.ihook"><span class="viewcode-link">[ソース]</span></a><a class="headerlink" href="#_pytest.main.Node.ihook" title="この定義へのパーマリンク">¶</a></dt>
<dd><p>fspath sensitive hook proxy used to call pytest hooks</p>
</dd></dl>

<dl class="attribute">
<dt id="_pytest.main.Node.keywords">
<tt class="descname">keywords</tt><em class="property"> = None</em><a class="headerlink" href="#_pytest.main.Node.keywords" title="この定義へのパーマリンク">¶</a></dt>
<dd><p>keywords/markers collected from all scopes</p>
</dd></dl>

<dl class="method">
<dt id="_pytest.main.Node.listchain">
<tt class="descname">listchain</tt><big>(</big><big>)</big><a class="reference internal" href="_modules/_pytest/main.html#Node.listchain"><span class="viewcode-link">[ソース]</span></a><a class="headerlink" href="#_pytest.main.Node.listchain" title="この定義へのパーマリンク">¶</a></dt>
<dd><p>return list of all parent collectors up to self,
starting from root of collection tree.</p>
</dd></dl>

<dl class="attribute">
<dt id="_pytest.main.Node.name">
<tt class="descname">name</tt><em class="property"> = None</em><a class="headerlink" href="#_pytest.main.Node.name" title="この定義へのパーマリンク">¶</a></dt>
<dd><p>a unique name within the scope of the parent node</p>
</dd></dl>

<dl class="attribute">
<dt id="_pytest.main.Node.nodeid">
<tt class="descname">nodeid</tt><a class="reference internal" href="_modules/_pytest/main.html#Node.nodeid"><span class="viewcode-link">[ソース]</span></a><a class="headerlink" href="#_pytest.main.Node.nodeid" title="この定義へのパーマリンク">¶</a></dt>
<dd><p>a ::-separated string denoting its collection tree address.</p>
</dd></dl>

<dl class="attribute">
<dt id="_pytest.main.Node.parent">
<tt class="descname">parent</tt><em class="property"> = None</em><a class="headerlink" href="#_pytest.main.Node.parent" title="この定義へのパーマリンク">¶</a></dt>
<dd><p>the parent collector node.</p>
</dd></dl>

<dl class="attribute">
<dt id="_pytest.main.Node.session">
<tt class="descname">session</tt><em class="property"> = None</em><a class="headerlink" href="#_pytest.main.Node.session" title="この定義へのパーマリンク">¶</a></dt>
<dd><p>the session this node is part of</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="_pytest.runner.CallInfo">
<em class="property">class </em><tt class="descclassname">_pytest.runner.</tt><tt class="descname">CallInfo</tt><big>(</big><em>func</em>, <em>when</em><big>)</big><a class="reference internal" href="_modules/_pytest/runner.html#CallInfo"><span class="viewcode-link">[ソース]</span></a><a class="headerlink" href="#_pytest.runner.CallInfo" title="この定義へのパーマリンク">¶</a></dt>
<dd><p>Result/Exception info a function invocation.</p>
<dl class="attribute">
<dt id="_pytest.runner.CallInfo.excinfo">
<tt class="descname">excinfo</tt><em class="property"> = None</em><a class="headerlink" href="#_pytest.runner.CallInfo.excinfo" title="この定義へのパーマリンク">¶</a></dt>
<dd><p>None or ExceptionInfo object.</p>
</dd></dl>

<dl class="attribute">
<dt id="_pytest.runner.CallInfo.when">
<tt class="descname">when</tt><em class="property"> = None</em><a class="headerlink" href="#_pytest.runner.CallInfo.when" title="この定義へのパーマリンク">¶</a></dt>
<dd><p>context of invocation: one of &#8220;setup&#8221;, &#8220;call&#8221;,
&#8220;teardown&#8221;, &#8220;memocollect&#8221;</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="_pytest.runner.TestReport">
<em class="property">class </em><tt class="descclassname">_pytest.runner.</tt><tt class="descname">TestReport</tt><big>(</big><em>nodeid</em>, <em>location</em>, <em>keywords</em>, <em>outcome</em>, <em>longrepr</em>, <em>when</em>, <em>sections=()</em>, <em>duration=0</em>, <em>**extra</em><big>)</big><a class="reference internal" href="_modules/_pytest/runner.html#TestReport"><span class="viewcode-link">[ソース]</span></a><a class="headerlink" href="#_pytest.runner.TestReport" title="この定義へのパーマリンク">¶</a></dt>
<dd><p>Basic test report object (also used for setup and teardown calls if
they fail).</p>
<dl class="attribute">
<dt id="_pytest.runner.TestReport.duration">
<tt class="descname">duration</tt><em class="property"> = None</em><a class="headerlink" href="#_pytest.runner.TestReport.duration" title="この定義へのパーマリンク">¶</a></dt>
<dd><p>time it took to run just the test</p>
</dd></dl>

<dl class="attribute">
<dt id="_pytest.runner.TestReport.keywords">
<tt class="descname">keywords</tt><em class="property"> = None</em><a class="headerlink" href="#_pytest.runner.TestReport.keywords" title="この定義へのパーマリンク">¶</a></dt>
<dd><p>a name -&gt; value dictionary containing all keywords and
markers associated with a test invocation.</p>
</dd></dl>

<dl class="attribute">
<dt id="_pytest.runner.TestReport.location">
<tt class="descname">location</tt><em class="property"> = None</em><a class="headerlink" href="#_pytest.runner.TestReport.location" title="この定義へのパーマリンク">¶</a></dt>
<dd><p>a (filesystempath, lineno, domaininfo) tuple indicating the
actual location of a test item - it might be different from the
collected one e.g. if a method is inherited from a different module.</p>
</dd></dl>

<dl class="attribute">
<dt id="_pytest.runner.TestReport.longrepr">
<tt class="descname">longrepr</tt><em class="property"> = None</em><a class="headerlink" href="#_pytest.runner.TestReport.longrepr" title="この定義へのパーマリンク">¶</a></dt>
<dd><p>None or a failure representation.</p>
</dd></dl>

<dl class="attribute">
<dt id="_pytest.runner.TestReport.nodeid">
<tt class="descname">nodeid</tt><em class="property"> = None</em><a class="headerlink" href="#_pytest.runner.TestReport.nodeid" title="この定義へのパーマリンク">¶</a></dt>
<dd><p>normalized collection node id</p>
</dd></dl>

<dl class="attribute">
<dt id="_pytest.runner.TestReport.outcome">
<tt class="descname">outcome</tt><em class="property"> = None</em><a class="headerlink" href="#_pytest.runner.TestReport.outcome" title="この定義へのパーマリンク">¶</a></dt>
<dd><p>test outcome, always one of &#8220;passed&#8221;, &#8220;failed&#8221;, &#8220;skipped&#8221;.</p>
</dd></dl>

<dl class="attribute">
<dt id="_pytest.runner.TestReport.sections">
<tt class="descname">sections</tt><em class="property"> = None</em><a class="headerlink" href="#_pytest.runner.TestReport.sections" title="この定義へのパーマリンク">¶</a></dt>
<dd><p>list of (secname, data) extra information which needs to
marshallable</p>
</dd></dl>

<dl class="attribute">
<dt id="_pytest.runner.TestReport.when">
<tt class="descname">when</tt><em class="property"> = None</em><a class="headerlink" href="#_pytest.runner.TestReport.when" title="この定義へのパーマリンク">¶</a></dt>
<dd><p>one of &#8216;setup&#8217;, &#8216;call&#8217;, &#8216;teardown&#8217; to indicate runtest phase.</p>
</dd></dl>

</dd></dl>

</div>


          </div>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>ナビゲーション</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="py-modindex.html" title="Pythonモジュール索引"
             >モジュール</a></li>
        <li class="right" >
          <a href="talks.html" title="講演とチュートリアル"
             >次へ</a> |</li>
        <li class="right" >
          <a href="doctest.html" title="モジュールやテストファイルの doctest"
             >前へ</a> |</li>
        <li><a href="contents.html">pytest-2.2.4.0</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 2011, holger krekel et alii.
      このドキュメントは <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3 で生成しました。
    </div>
  </body>
</html>