<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <p>Another way would be to somehow get the "who tests what" feature
      implemented, so that you could segregate your results by which
      test covered the code. 
      <a class="moz-txt-link-freetext" href="https://bitbucket.org/ned/coveragepy/issues/170/show-who-tests-what">https://bitbucket.org/ned/coveragepy/issues/170/show-who-tests-what</a></p>
    <p>But that is a big effort.<br>
    </p>
    <p>--Ned.<br>
    </p>
    <div class="moz-cite-prefix">On 10/17/16 11:17 AM, Shai Cantor
      wrote:<br>
    </div>
    <blockquote
cite="mid:CA+BoLDZBnuxTLfxaY565=3-P8UZP=8dcpPu7WTG0pQP2+5H5Ag@mail.gmail.com"
      type="cite">
      <div dir="ltr">I wish.<br>
        In some setups, companies spin up servers that are dedicated for
        testing by multiple clients.<br>
        Those cannot be frequently restarted.
        <div>Do you think there can be another way?<br>
          <div class="gmail_extra"><br>
            <div class="gmail_quote">On Mon, Oct 17, 2016 at 4:00 PM, <span
                dir="ltr">&lt;<a moz-do-not-send="true"
                  href="mailto:testing-in-python-request@lists.idyll.org"
                  target="_blank">testing-in-python-request@lists.idyll.org</a>&gt;</span>
              wrote:<br>
              <blockquote class="gmail_quote" style="margin:0 0 0
                .8ex;border-left:1px #ccc solid;padding-left:1ex">Send
                testing-in-python mailing list submissions to<br>
                        <a moz-do-not-send="true"
                  href="mailto:testing-in-python@lists.idyll.org">testing-in-python@lists.idyll.<wbr>org</a><br>
                <br>
                To subscribe or unsubscribe via the World Wide Web,
                visit<br>
                        <a moz-do-not-send="true"
                  href="http://lists.idyll.org/listinfo/testing-in-python"
                  rel="noreferrer" target="_blank">http://lists.idyll.org/<wbr>listinfo/testing-in-python</a><br>
                or, via email, send a message with subject or body
                'help' to<br>
                        <a moz-do-not-send="true"
                  href="mailto:testing-in-python-request@lists.idyll.org">testing-in-python-request@<wbr>lists.idyll.org</a><br>
                <br>
                You can reach the person managing the list at<br>
                        <a moz-do-not-send="true"
                  href="mailto:testing-in-python-owner@lists.idyll.org">testing-in-python-owner@lists.<wbr>idyll.org</a><br>
                <br>
                When replying, please edit your Subject line so it is
                more specific<br>
                than "Re: Contents of testing-in-python digest..."<br>
                <br>
                Today's Topics:<br>
                <br>
                   1. Re: Resetting or Restarting coverage.py trace (Ned
                Batchelder)<br>
                   2. Re: pytest (James)<br>
                <br>
                <br>
                ---------- Forwarded message ----------<br>
                From: Ned Batchelder &lt;<a moz-do-not-send="true"
                  href="mailto:ned@nedbatchelder.com">ned@nedbatchelder.com</a>&gt;<br>
                To: <a moz-do-not-send="true"
                  href="mailto:testing-in-python@lists.idyll.org">testing-in-python@lists.idyll.org</a><br>
                Cc: <br>
                Date: Mon, 17 Oct 2016 07:09:33 -0400<br>
                Subject: Re: [TIP] Resetting or Restarting coverage.py
                trace<br>
                <div bgcolor="#FFFFFF" text="#000000">
                  <p>Wouldn't it be easiest to restart the process
                    between the two phases?</p>
                  <p>--Ned.<br>
                  </p>
                  <br>
                  <div class="m_-6570471573399858068moz-cite-prefix">On
                    10/17/16 4:22 AM, Shai Cantor wrote:<br>
                  </div>
                  <blockquote type="cite">
                    <div dir="ltr">I'm trying to find the coverage of
                      multiple processes that are running on multiple
                      test phases.
                      <div>For example:</div>
                      <div>
                        <ul>
                          <li>A CI server that is conducting tests that
                            make HTTP calls to another server for
                            functional tests phase.<br>
                          </li>
                          <li>The same CI server is conducting tests
                            that make other HTTP calls to the same
                            server as part of the performance test
                            phase.</li>
                        </ul>
                        <div>I would like to measure coverage for the
                          functional test phase, reset the coverage and
                          start measuring again from scratch for the
                          performance test phase.</div>
                      </div>
                      <div>
                        <div class="gmail_extra"><br>
                          <div class="gmail_quote">On Sun, Oct 16, 2016
                            at 10:00 PM, <span dir="ltr">&lt;<a
                                moz-do-not-send="true"
                                href="mailto:testing-in-python-request@lists.idyll.org"
                                target="_blank">testing-in-python-request@<wbr>lists.idyll.org</a>&gt;</span>
                            wrote:<br>
                            <blockquote class="gmail_quote"
                              style="margin:0 0 0 .8ex;border-left:1px
                              #ccc solid;padding-left:1ex">Send
                              testing-in-python mailing list submissions
                              to<br>
                                      <a moz-do-not-send="true"
                                href="mailto:testing-in-python@lists.idyll.org"
                                target="_blank">testing-in-python@lists.idyll.<wbr>org</a><br>
                              <br>
                              To subscribe or unsubscribe via the World
                              Wide Web, visit<br>
                                      <a moz-do-not-send="true"
                                href="http://lists.idyll.org/listinfo/testing-in-python"
                                rel="noreferrer" target="_blank">http://lists.idyll.org/listinf<wbr>o/testing-in-python</a><br>
                              or, via email, send a message with subject
                              or body 'help' to<br>
                                      <a moz-do-not-send="true"
                                href="mailto:testing-in-python-request@lists.idyll.org"
                                target="_blank">testing-in-python-request@list<wbr>s.idyll.org</a><br>
                              <br>
                              You can reach the person managing the list
                              at<br>
                                      <a moz-do-not-send="true"
                                href="mailto:testing-in-python-owner@lists.idyll.org"
                                target="_blank">testing-in-python-owner@lists.<wbr>idyll.org</a><br>
                              <br>
                              When replying, please edit your Subject
                              line so it is more specific<br>
                              than "Re: Contents of testing-in-python
                              digest..."<br>
                              <br>
                              Today's Topics:<br>
                              <br>
                                 1. Resetting or Restarting coverage.py
                              trace (Shai Cantor)<br>
                                 2. Re: Resetting or Restarting
                              coverage.py trace (Ned Batchelder)<br>
                                 3. Re: are the absolute paths in
                              .coverage necessary? (Chris Withers)<br>
                              <br>
                              <br>
                              ---------- Forwarded message ----------<br>
                              From: Shai Cantor &lt;<a
                                moz-do-not-send="true"
                                href="mailto:shai@sealights.io"
                                target="_blank">shai@sealights.io</a>&gt;<br>
                              To: <a moz-do-not-send="true"
                                href="mailto:testing-in-python@lists.idyll.org"
                                target="_blank">testing-in-python@lists.<wbr>idyll.org</a><br>
                              Cc: <br>
                              Date: Sun, 16 Oct 2016 09:36:42 +0300<br>
                              Subject: [TIP] Resetting or Restarting
                              coverage.py trace<br>
                              <div dir="ltr">Hi,
                                <div><br>
                                </div>
                                <div>So I'm using coverage.py API</div>
                                <div>
                                  <pre style="box-sizing:border-box;font-family:consolas,&quot;andale mono wt&quot;,&quot;andale mono&quot;,&quot;lucida console&quot;,&quot;lucida sans typewriter&quot;,&quot;dejavu sans mono&quot;,&quot;bitstream vera sans mono&quot;,&quot;liberation mono&quot;,&quot;nimbus mono l&quot;,monaco,&quot;courier new&quot;,courier,monospace;font-size:12px;margin-top:0px;margin-bottom:0px;padding:12px;line-height:1.5;overflow:auto;color:rgb(64,64,64)"><span class="m_-6570471573399858068m_3218531326940723117gmail-kn" style="box-sizing:border-box">import</span> <span class="m_-6570471573399858068m_3218531326940723117gmail-nn" style="box-sizing:border-box;color:rgb(85,85,85)">coverage</span>

<span class="m_-6570471573399858068m_3218531326940723117gmail-n" style="box-sizing:border-box;color:rgb(51,51,51)">cov</span> <span class="m_-6570471573399858068m_3218531326940723117gmail-o" style="box-sizing:border-box;font-weight:bold">=</span> <span class="m_-6570471573399858068m_3218531326940723117gmail-n" style="box-sizing:border-box;color:rgb(51,51,51)">coverage</span><span class="m_-6570471573399858068m_3218531326940723117gmail-o" style="box-sizing:border-box;font-weight:bold">.</span><span class="m_-6570471573399858068m_3218531326940723117gmail-n" style="box-sizing:border-box;color:rgb(51,51,51)">Coverage</span><span class="m_-6570471573399858068m_3218531326940723117gmail-p" style="box-sizing:border-box">()</span>
<span class="m_-6570471573399858068m_3218531326940723117gmail-n" style="box-sizing:border-box;color:rgb(51,51,51)">cov</span><span class="m_-6570471573399858068m_3218531326940723117gmail-o" style="box-sizing:border-box;font-weight:bold">.</span><span class="m_-6570471573399858068m_3218531326940723117gmail-n" style="box-sizing:border-box;color:rgb(51,51,51)">start</span><span class="m_-6570471573399858068m_3218531326940723117gmail-p" style="box-sizing:border-box">()</span>

<span class="m_-6570471573399858068m_3218531326940723117gmail-c1" style="box-sizing:border-box;color:rgb(153,153,136);font-style:italic"># .. call your code ..</span>

<span class="m_-6570471573399858068m_3218531326940723117gmail-n" style="box-sizing:border-box;color:rgb(51,51,51)">cov</span><span class="m_-6570471573399858068m_3218531326940723117gmail-o" style="box-sizing:border-box;font-weight:bold">.</span><span class="m_-6570471573399858068m_3218531326940723117gmail-n" style="box-sizing:border-box;color:rgb(51,51,51)">stop</span><span class="m_-6570471573399858068m_3218531326940723117gmail-p" style="box-sizing:border-box">()</span>
<span class="m_-6570471573399858068m_3218531326940723117gmail-n" style="box-sizing:border-box;color:rgb(51,51,51)">cov</span><span class="m_-6570471573399858068m_3218531326940723117gmail-o" style="box-sizing:border-box;font-weight:bold">.</span><span class="m_-6570471573399858068m_3218531326940723117gmail-n" style="box-sizing:border-box;color:rgb(51,51,51)">save</span><span class="m_-6570471573399858068m_3218531326940723117gmail-p" style="box-sizing:border-box">()</span></pre>
                                </div>
                                <div><br>
                                </div>
                                <div>The main thread creates a coverage
                                  instance and starts it.</div>
                                <div>During the lifetime of the program
                                  I have multiple threads and I need
                                  every once in while to reset or
                                  restart the coverage process (or clear
                                  coverage data) from one of the
                                  underlying threads.</div>
                                <div>Problem is that tracing is stopped
                                  after I do that. I guess it's because
                                  I start it from another thread.</div>
                                <div><br>
                                </div>
                                <div>Is there a way I can reset/restart
                                  coverage from another thread or
                                  manually clear coverage data?</div>
                                <div><br>
                                </div>
                                <div>Thanks</div>
                                <div><br>
                                </div>
                              </div>
                              <br>
                              <br>
                              ---------- Forwarded message ----------<br>
                              From: Ned Batchelder &lt;<a
                                moz-do-not-send="true"
                                href="mailto:ned@nedbatchelder.com"
                                target="_blank">ned@nedbatchelder.com</a>&gt;<br>
                              To: <a moz-do-not-send="true"
                                href="mailto:testing-in-python@lists.idyll.org"
                                target="_blank">testing-in-python@lists.<wbr>idyll.org</a><br>
                              Cc: <br>
                              Date: Sun, 16 Oct 2016 12:10:48 -0400<br>
                              Subject: Re: [TIP] Resetting or Restarting
                              coverage.py trace<br>
                              <div bgcolor="#FFFFFF" text="#000000"> On
                                10/16/16 2:36 AM, Shai Cantor wrote:<br>
                                <blockquote type="cite">
                                  <div dir="ltr">Hi,
                                    <div><br>
                                    </div>
                                    <div>So I'm using coverage.py API</div>
                                    <div>
                                      <pre style="box-sizing:border-box;font-family:consolas,&quot;andale mono wt&quot;,&quot;andale mono&quot;,&quot;lucida console&quot;,&quot;lucida sans typewriter&quot;,&quot;dejavu sans mono&quot;,&quot;bitstream vera sans mono&quot;,&quot;liberation mono&quot;,&quot;nimbus mono l&quot;,monaco,&quot;courier new&quot;,courier,monospace;font-size:12px;margin-top:0px;margin-bottom:0px;padding:12px;line-height:1.5;overflow:auto;color:rgb(64,64,64)"><span class="m_-6570471573399858068m_7611045549709367566gmail-kn" style="box-sizing:border-box">import</span> <span class="m_-6570471573399858068m_7611045549709367566gmail-nn" style="box-sizing:border-box;color:rgb(85,85,85)">coverage</span>

<span class="m_-6570471573399858068m_7611045549709367566gmail-n" style="box-sizing:border-box;color:rgb(51,51,51)">cov</span> <span class="m_-6570471573399858068m_7611045549709367566gmail-o" style="box-sizing:border-box;font-weight:bold">=</span> <span class="m_-6570471573399858068m_7611045549709367566gmail-n" style="box-sizing:border-box;color:rgb(51,51,51)">coverage</span><span class="m_-6570471573399858068m_7611045549709367566gmail-o" style="box-sizing:border-box;font-weight:bold">.</span><span class="m_-6570471573399858068m_7611045549709367566gmail-n" style="box-sizing:border-box;color:rgb(51,51,51)">Coverage</span><span class="m_-6570471573399858068m_7611045549709367566gmail-p" style="box-sizing:border-box">()</span>
<span class="m_-6570471573399858068m_7611045549709367566gmail-n" style="box-sizing:border-box;color:rgb(51,51,51)">cov</span><span class="m_-6570471573399858068m_7611045549709367566gmail-o" style="box-sizing:border-box;font-weight:bold">.</span><span class="m_-6570471573399858068m_7611045549709367566gmail-n" style="box-sizing:border-box;color:rgb(51,51,51)">start</span><span class="m_-6570471573399858068m_7611045549709367566gmail-p" style="box-sizing:border-box">()</span>

<span class="m_-6570471573399858068m_7611045549709367566gmail-c1" style="box-sizing:border-box;color:rgb(153,153,136);font-style:italic"># .. call your code ..</span>

<span class="m_-6570471573399858068m_7611045549709367566gmail-n" style="box-sizing:border-box;color:rgb(51,51,51)">cov</span><span class="m_-6570471573399858068m_7611045549709367566gmail-o" style="box-sizing:border-box;font-weight:bold">.</span><span class="m_-6570471573399858068m_7611045549709367566gmail-n" style="box-sizing:border-box;color:rgb(51,51,51)">stop</span><span class="m_-6570471573399858068m_7611045549709367566gmail-p" style="box-sizing:border-box">()</span>
<span class="m_-6570471573399858068m_7611045549709367566gmail-n" style="box-sizing:border-box;color:rgb(51,51,51)">cov</span><span class="m_-6570471573399858068m_7611045549709367566gmail-o" style="box-sizing:border-box;font-weight:bold">.</span><span class="m_-6570471573399858068m_7611045549709367566gmail-n" style="box-sizing:border-box;color:rgb(51,51,51)">save</span><span class="m_-6570471573399858068m_7611045549709367566gmail-p" style="box-sizing:border-box">()</span></pre>
                                    </div>
                                    <div><br>
                                    </div>
                                    <div>The main thread creates a
                                      coverage instance and starts it.</div>
                                    <div>During the lifetime of the
                                      program I have multiple threads
                                      and I need every once in while to
                                      reset or restart the coverage
                                      process (or clear coverage data)
                                      from one of the underlying
                                      threads.</div>
                                    <div>Problem is that tracing is
                                      stopped after I do that. I guess
                                      it's because I start it from
                                      another thread.</div>
                                    <div><br>
                                    </div>
                                    <div>Is there a way I can
                                      reset/restart coverage from
                                      another thread or manually clear
                                      coverage data?</div>
                                    <br>
                                  </div>
                                </blockquote>
                                I haven't heard this need before, to
                                occasionally reset or clear the coverage
                                data from one of many threads. Can you
                                say more about what the bigger picture
                                is here? There might be an easier way to
                                get it done.<br>
                                <br>
                                --Ned.<br>
                              </div>
                              <br>
                              <br>
                              ---------- Forwarded message ----------<br>
                              From: Chris Withers &lt;<a
                                moz-do-not-send="true"
                                href="mailto:chris@simplistix.co.uk"
                                target="_blank">chris@simplistix.co.uk</a>&gt;<br>
                              To: Ned Batchelder &lt;<a
                                moz-do-not-send="true"
                                href="mailto:ned@nedbatchelder.com"
                                target="_blank">ned@nedbatchelder.com</a>&gt;,
                              "<a moz-do-not-send="true"
                                href="mailto:testing-in-python@lists.idyll.org"
                                target="_blank">testing-in-python@lists.<wbr>idyll.org</a>"
                              &lt;<a moz-do-not-send="true"
                                href="mailto:testing-in-python@lists.idyll.org"
                                target="_blank">testing-in-python@lists.<wbr>idyll.org</a>&gt;<br>
                              Cc: <br>
                              Date: Sun, 16 Oct 2016 19:44:38 +0100<br>
                              Subject: Re: [TIP] are the absolute paths
                              in .coverage necessary?<br>
                              Hi Ned,<br>
                              <br>
                              Sorry, I meant: do the paths recorded in
                              the .coverage files need to be absolute or
                              could Coverage be changed to just record
                              the path relatively to the current working
                              directory at the start of execution?<br>
                              <br>
                              cheers,<br>
                              <br>
                              Chris<br>
                              <br>
                              <br>
                              On 12/10/2016 22:31, Ned Batchelder wrote:<br>
                              <blockquote class="gmail_quote"
                                style="margin:0 0 0 .8ex;border-left:1px
                                #ccc solid;padding-left:1ex"> Chris, as
                                far as I can tell, they do not have to
                                be absolute. As you can<br>
                                see from the sample of my rc file, you
                                can replace an arbitrary prefix<br>
                                with *, and it will work just fine.  How
                                about this:<br>
                                <br>
                                [paths]<br>
                                mylib =<br>
                                   mylib<br>
                                   */workspace/PYTHON/*/mylib<br>
                                tests =<br>
                                   tests<br>
                                   */workspace/PYTHON/*/tests<br>
                                <br>
                                --Ned.<br>
                                <br>
                                <br>
                                On 10/12/16 10:59 AM, Chris Withers
                                wrote:<br>
                                <blockquote class="gmail_quote"
                                  style="margin:0 0 0
                                  .8ex;border-left:1px #ccc
                                  solid;padding-left:1ex"> What I
                                  currently have is:<br>
                                  <br>
                                  [paths]<br>
                                  mylib =<br>
                                     mylib<br>
                                     /data/jenkins/jobs/mylib-test<wbr>/workspace/PYTHON/*/mylib<br>
                                  tests =<br>
                                     tests<br>
                                     /data/jenkins/jobs/mylib-test<wbr>/workspace/PYTHON/*/tests<br>
                                  <br>
                                  How can I remove the absolute bits of
                                  that?<br>
                                  <br>
                                  But, back to my original question: why
                                  are the paths in .coverage<br>
                                  absolute in the first place? :-)<br>
                                  <br>
                                  Chris<br>
                                  <br>
                                  On 12/10/2016 15:53, Ned Batchelder
                                  wrote:<br>
                                  <blockquote class="gmail_quote"
                                    style="margin:0 0 0
                                    .8ex;border-left:1px #ccc
                                    solid;padding-left:1ex"> Chris, can
                                    you show the absolute paths you are
                                    using?  I have this in my<br>
                                    rc file to deal with varieties of
                                    CI:<br>
                                    <br>
                                         [paths]<br>
                                         source =<br>
                                             .<br>
                                             *\coverage\trunk<br>
                                             */coverage/trunk<br>
                                             *\coveragepy<br>
                                    <br>
                                    --Ned.<br>
                                    <br>
                                    <br>
                                    On 10/12/16 10:00 AM, Chris Withers
                                    wrote:<br>
                                    <blockquote class="gmail_quote"
                                      style="margin:0 0 0
                                      .8ex;border-left:1px #ccc
                                      solid;padding-left:1ex"> Hi Ned,<br>
                                      <br>
                                      Are the absolute paths necessary
                                      in .coverage?<br>
                                      <br>
                                      The reason I ask is that if, for
                                      example, they were relative to the<br>
                                      cwd, then I wouldn't need a
                                      .coveragerc with a whole bunch of
                                      paths<br>
                                      predicated on the exact filesystem
                                      layout of my CI server.<br>
                                      <br>
                                      thoughts?<br>
                                      <br>
                                      Chris<br>
                                    </blockquote>
                                  </blockquote>
                                </blockquote>
                              </blockquote>
                              <br>
                              <br>
                              <br>
                              <br>
                              ______________________________<wbr>_________________<br>
                              testing-in-python mailing list<br>
                              <a moz-do-not-send="true"
                                href="mailto:testing-in-python@lists.idyll.org"
                                target="_blank">testing-in-python@lists.idyll.<wbr>org</a><br>
                              <a moz-do-not-send="true"
                                href="http://lists.idyll.org/listinfo/testing-in-python"
                                rel="noreferrer" target="_blank">http://lists.idyll.org/listinf<wbr>o/testing-in-python</a><br>
                              <br>
                            </blockquote>
                          </div>
                          <br>
                        </div>
                      </div>
                    </div>
                    <br>
                    <fieldset
                      class="m_-6570471573399858068mimeAttachmentHeader"></fieldset>
                    <br>
                    <pre>______________________________<wbr>_________________
testing-in-python mailing list
<a moz-do-not-send="true" class="m_-6570471573399858068moz-txt-link-abbreviated" href="mailto:testing-in-python@lists.idyll.org" target="_blank">testing-in-python@lists.idyll.<wbr>org</a>
<a moz-do-not-send="true" class="m_-6570471573399858068moz-txt-link-freetext" href="http://lists.idyll.org/listinfo/testing-in-python" target="_blank">http://lists.idyll.org/<wbr>listinfo/testing-in-python</a>
</pre>
    </blockquote>
    

  </div>



---------- Forwarded message ----------
From: James &lt;<a moz-do-not-send="true" href="mailto:bjlockie@lockie.ca">bjlockie@lockie.ca</a>&gt;
To: Bruno Oliveira &lt;<a moz-do-not-send="true" href="mailto:nicoddemus@gmail.com">nicoddemus@gmail.com</a>&gt;, <a moz-do-not-send="true" href="mailto:testing-in-python@lists.idyll.org">testing-in-python@lists.idyll.org</a>
Cc: 
Date: Mon, 17 Oct 2016 09:00:39 -0400
Subject: Re: [TIP] pytest

  
    
  
  <div bgcolor="#FFFFFF" text="#000000">
    <p>The output was:

      a = &lt;testscript.TestAclasss instance at 0x7f3ca6bf83b0&gt;

      

          def test_foo(a):

      &gt;       assert a == '1'

      E       assert &lt;testscript.TestAclasss instance at
      0x7f3ca6bf83b0&gt; == '1'

      

      testscript.py:6: AssertionError

      1 failed in 0.03 seconds

    </p>
    <p>

    </p>
    <p>The missing "self" fixed it.

    </p>
    

    <div class="m_-5885689400719985585moz-cite-prefix">On 2016-10-16 12:56 AM, Bruno Oliveira
      wrote:

    </div>
    <blockquote type="cite">
      <div dir="ltr">
        <div class="m_-5885689400719985585markdown-here-wrapper">
          <p style="margin:1.2em 0px!important">Hi James,</p>
          <p style="margin:1.2em 0px!important">What error do you get?
            From your example it is missing a <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">self</code>
            argument, otherwise it should work just fine.</p>
          <p style="margin:1.2em 0px!important">Cheers,

            Bruno.</p>
          <div title="MDH:SGkgSmFtZXMsPGRpdj48YnI+PC9kaXY+PGRpdj5XaGF0IGVycm9yIGRvIHlvdSBnZXQ/IEZyb20geW91ciBleGFtcGxlIGl0IGlzIG1pc3NpbmcgYSBgc2VsZmAgYXJndW1lbnQsIG90aGVyd2lzZSBp
dCBzaG91bGQgd29yayBqdXN0IGZpbmUuPC9kaXY+PGRpdj48YnI+PC9kaXY+PGRpdj5DaGVlcnMs
            PC9kaXY+PGRpdj5CcnVuby48L2Rpdj4=" style="height:0;width:0;max-height:0;max-width:0;overflow:hidden;font-size:0em;padding:0;margin:0">​</div>
        </div>
      </div>
      

      <div class="gmail_quote">
        <div dir="ltr">On Sat, Oct 15, 2016 at 11:03 AM James &lt;<a moz-do-not-send="true" href="mailto:bjlockie@lockie.ca" target="_blank">bjlockie@lockie.ca</a>&gt;
          wrote:

        </div>
        <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
          <div bgcolor="#FFFFFF" text="#000000" class="m_-5885689400719985585gmail_msg">
            <p class="m_-5885689400719985585gmail_msg">I tried to make it work with a class:

            </p>
            <p class="m_-5885689400719985585gmail_msg">import pytest

              

              # testscript.py

              class TestAclasss:</p>
          </div>
          <div bgcolor="#FFFFFF" text="#000000" class="m_-5885689400719985585gmail_msg">
            <p class="m_-5885689400719985585gmail_msg">

                  def test_foo(a):

                      assert a == '1'

            </p>
          </div>
          <div bgcolor="#FFFFFF" text="#000000" class="m_-5885689400719985585gmail_msg"> Do I
            need to do something in the __init__ function?</div>
          <div bgcolor="#FFFFFF" text="#000000" class="m_-5885689400719985585gmail_msg">

            

            

            

            <div class="m_-5885689400719985585m_-3825917875471976212moz-cite-prefix m_-5885689400719985585gmail_msg">On
              2016-10-14 02:50 PM, Bruno Oliveira wrote:

            </div>
          </div>
          <div bgcolor="#FFFFFF" text="#000000" class="m_-5885689400719985585gmail_msg">
            <blockquote type="cite" class="m_-5885689400719985585gmail_msg">
              <div dir="ltr" class="m_-5885689400719985585gmail_msg">
                <div dir="ltr" class="m_-5885689400719985585gmail_msg">
                  <div class="m_-5885689400719985585m_-3825917875471976212markdown-here-wrapper m_-5885689400719985585gmail_msg">
                    <p style="margin:1.2em 0px!important" class="m_-5885689400719985585gmail_msg">Hi James,</p>
                    <p style="margin:1.2em 0px!important" class="m_-5885689400719985585gmail_msg">Thanks for posting the complete
                      example.</p>
                    <p style="margin:1.2em 0px!important" class="m_-5885689400719985585gmail_msg">There are some problems here,
                      both general Python problems and some related to
                      how you are using pytest:</p>
                    <ol style="margin:1.2em 0px;padding-left:2em" class="m_-5885689400719985585gmail_msg">
                      <li style="margin:0.5em 0px" class="m_-5885689400719985585gmail_msg"><code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline" class="m_-5885689400719985585gmail_msg">testscript.py</code>
                        has no access to the <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline" class="m_-5885689400719985585gmail_msg">A</code>
                        function because it doesn’t import it. </li>
                      <li style="margin:0.5em 0px" class="m_-5885689400719985585gmail_msg">You
                        probably want to declare your fixture in a <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline" class="m_-5885689400719985585gmail_msg">conftest.py</code>
                        file so pytest can make it available for all
                        tests in your test suite.</li>
                      <li style="margin:0.5em 0px" class="m_-5885689400719985585gmail_msg">You
                        have to first declare your option using the <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline" class="m_-5885689400719985585gmail_msg">pytest_addoption</code>
                        hook.</li>
                      <li style="margin:0.5em 0px" class="m_-5885689400719985585gmail_msg">Since
                        you intend to provide the value passed in the
                        command line to the tests using a fixture, it is
                        simpler to skip the test in the fixture itself.</li>
                    </ol>
                    <p style="margin:1.2em 0px!important" class="m_-5885689400719985585gmail_msg">Here’s the full example with my
                      suggestions:</p>
                    <pre style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;margin:1.2em 0px" class="m_-5885689400719985585gmail_msg"><code class="m_-5885689400719985585m_-3825917875471976212hljs m_-5885689400719985585m_-3825917875471976212language-python m_-5885689400719985585gmail_msg" style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline;white-space:pre-wrap;overflow:auto;border-radius:3px;border:1px solid rgb(204,204,204);padding:0.5em 0.7em;display:block!important;display:block;overflow-x:auto;padding:0.5em;background:rgb(35,36,31);color:rgb(248,248,242)"><span class="m_-5885689400719985585m_-3825917875471976212hljs-comment m_-5885689400719985585gmail_msg" style="color:rgb(117,113,94)"># conftest.py</span>
<span class="m_-5885689400719985585m_-3825917875471976212hljs-keyword m_-5885689400719985585gmail_msg" style="color:rgb(249,38,114)">import</span> pytest

<span class="m_-5885689400719985585m_-3825917875471976212hljs-decorator m_-5885689400719985585gmail_msg" style="color:rgb(117,113,94)">@pytest.fixture(scope='module'<wbr>)</span>
<span class="m_-5885689400719985585m_-3825917875471976212hljs-function m_-5885689400719985585gmail_msg" style="color:rgb(249,38,114)"><span class="m_-5885689400719985585m_-3825917875471976212hljs-keyword m_-5885689400719985585gmail_msg" style="color:rgb(249,38,114);color:rgb(102,217,239)">def</span> <span class="m_-5885689400719985585m_-3825917875471976212hljs-title m_-5885689400719985585gmail_msg" style="color:rgb(166,226,46)">a</span><span class="m_-5885689400719985585m_-3825917875471976212hljs-params m_-5885689400719985585gmail_msg" style="color:rgb(248,248,242)">(request)</span>:</span>
    value = request.config.getoption(<span class="m_-5885689400719985585m_-3825917875471976212hljs-string m_-5885689400719985585gmail_msg" style="color:rgb(230,219,116)">"A"</span>)
    <span class="m_-5885689400719985585m_-3825917875471976212hljs-keyword m_-5885689400719985585gmail_msg" style="color:rgb(249,38,114)">if</span> <span class="m_-5885689400719985585m_-3825917875471976212hljs-keyword m_-5885689400719985585gmail_msg" style="color:rgb(249,38,114)">not</span> value:
        pytest.skip(<span class="m_-5885689400719985585m_-3825917875471976212hljs-string m_-5885689400719985585gmail_msg" style="color:rgb(230,219,116)">'test needs -A option to run'</span>)
    <span class="m_-5885689400719985585m_-3825917875471976212hljs-keyword m_-5885689400719985585gmail_msg" style="color:rgb(249,38,114)">return</span> value

<span class="m_-5885689400719985585m_-3825917875471976212hljs-function m_-5885689400719985585gmail_msg" style="color:rgb(249,38,114)"><span class="m_-5885689400719985585m_-3825917875471976212hljs-keyword m_-5885689400719985585gmail_msg" style="color:rgb(249,38,114);color:rgb(102,217,239)">def</span> <span class="m_-5885689400719985585m_-3825917875471976212hljs-title m_-5885689400719985585gmail_msg" style="color:rgb(166,226,46)">pytest_addoption</span><span class="m_-5885689400719985585m_-3825917875471976212hljs-params m_-5885689400719985585gmail_msg" style="color:rgb(248,248,242)">(parser)</span>:</span>
    parser.addoption(<span class="m_-5885689400719985585m_-3825917875471976212hljs-string m_-5885689400719985585gmail_msg" style="color:rgb(230,219,116)">"--A"</span>, action=<span class="m_-5885689400719985585m_-3825917875471976212hljs-string m_-5885689400719985585gmail_msg" style="color:rgb(230,219,116)">"store"</span>, default=<span class="m_-5885689400719985585m_-3825917875471976212hljs-keyword m_-5885689400719985585gmail_msg" style="color:rgb(249,38,114)">None</span>, help=<span class="m_-5885689400719985585m_-3825917875471976212hljs-string m_-5885689400719985585gmail_msg" style="color:rgb(230,219,116)">"a option"</span>)    

<span class="m_-5885689400719985585m_-3825917875471976212hljs-comment m_-5885689400719985585gmail_msg" style="color:rgb(117,113,94)"># testscript.py</span>
<span class="m_-5885689400719985585m_-3825917875471976212hljs-function m_-5885689400719985585gmail_msg" style="color:rgb(249,38,114)"><span class="m_-5885689400719985585m_-3825917875471976212hljs-keyword m_-5885689400719985585gmail_msg" style="color:rgb(249,38,114);color:rgb(102,217,239)">def</span> <span class="m_-5885689400719985585m_-3825917875471976212hljs-title m_-5885689400719985585gmail_msg" style="color:rgb(166,226,46)">test_foo</span><span class="m_-5885689400719985585m_-3825917875471976212hljs-params m_-5885689400719985585gmail_msg" style="color:rgb(248,248,242)">(a)</span>:</span>
    <span class="m_-5885689400719985585m_-3825917875471976212hljs-keyword m_-5885689400719985585gmail_msg" style="color:rgb(249,38,114)">assert</span> a == <span class="m_-5885689400719985585m_-3825917875471976212hljs-string m_-5885689400719985585gmail_msg" style="color:rgb(230,219,116)">'1'</span>
</code></pre>
                    <p style="margin:1.2em 0px!important" class="m_-5885689400719985585gmail_msg">Running it:</p>
                    <pre style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;margin:1.2em 0px" class="m_-5885689400719985585gmail_msg"><code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline;white-space:pre-wrap;overflow:auto;border-radius:3px;border:1px solid rgb(204,204,204);padding:0.5em 0.7em;display:block!important" class="m_-5885689400719985585gmail_msg">$ py.test testscript.py -q
s
1 skipped in 0.01 seconds

$ py.test testscript.py -q --A 1
.
1 passed in 0.01 seconds

$ py.test testscript.py -q --A 2
F
==============================<wbr>==== FAILURES ==============================<wbr>=====
______________________________<wbr>____ test_foo ______________________________<wbr>_____

a = '2'

    def test_foo(a):
&gt;       assert a == '1'
E       assert '2' == '1'
E         - 2
E         + 1

testscript.py:6: AssertionError
1 failed in 0.07 seconds
</code></pre>
                    <p style="margin:1.2em 0px!important" class="m_-5885689400719985585gmail_msg">Hope that helps,

                      Bruno.</p>
                    <div title="MDH:SGkgSm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C9kaXY+PGRpdiBjbGFzcz0iZ21haWxf
bXNnIj5FICZuYnNwOyAmbmJzcDsgJm5ic3A7ICZuYnNwOyAtIDI8L2Rpdj48ZGl2IGNsYXNzPSJn
bWFpbF9tc2ciPkUgJm5ic3A7ICZuYnNwOyAmbmJzcDsgJm5ic3A7ICsgMTwvZGl2PjxkaXYgY2xh
c3M9ImdtYWlsX21zZyI+PGJyPjwvZGl2PjxkaXYgY2xhc3M9ImdtYWlsX21zZyI+dGVzdHNjcmlw
dC5weTo2OiBBc3NlcnRpb25FcnJvcjwvZGl2PjxkaXYgY2xhc3M9ImdtYWlsX21zZyI+MSBmYWls
ZWQgaW4gMC4wNyBzZWNvbmRzPC9kaXY+PC9kaXY+PGRpdiBjbGFzcz0iZ21haWxfbXNnIj5gYGA8
L2Rpdj48ZGl2IGNsYXNzPSJnbWFpbF9tc2ciPjxicj48L2Rpdj48ZGl2IGNsYXNzPSJnbWFpbF9t
c2ciPkhvcGUgdGhhdCBoZWxwcyw8L2Rpdj48ZGl2IGNsYXNzPSJnbWFpbF9tc2ciPkJydW5vLjwv
                      ZGl2Pg==" style="height:0;width:0;max-height:0;max-width:0;overflow:hidden;font-size:0em;padding:0;margin:0" class="m_-5885689400719985585gmail_msg">​</div>
                  </div>
                  <div class="m_-5885689400719985585gmail_msg">

                  </div>
                  <div class="m_-5885689400719985585gmail_msg">

                  </div>
                </div>
                <div class="gmail_quote m_-5885689400719985585gmail_msg">
                  <div dir="ltr" class="m_-5885689400719985585gmail_msg">On Fri, Oct 14, 2016
                    at 3:07 PM James &lt;<a moz-do-not-send="true" href="mailto:bjlockie@lockie.ca" class="m_-5885689400719985585gmail_msg" target="_blank">bjlockie@lockie.ca</a>&gt; wrote:

                  </div>
                  <blockquote class="gmail_quote m_-5885689400719985585gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
                    <div bgcolor="#FFFFFF" text="#000000" class="m_-5885689400719985585gmail_msg"> 

                      Here is the exact code:

                      $ cat testconfig.py 

                      import pytest</div>
                    <div bgcolor="#FFFFFF" text="#000000" class="m_-5885689400719985585gmail_msg">

                      

                      @pytest.fixture(scope='module'<wbr>)

                      def A(request):

                          return request.config.getoption("--A"<wbr>)

                      

                    </div>
                    <div bgcolor="#FFFFFF" text="#000000" class="m_-5885689400719985585gmail_msg"> $ cat testscript.py 

                      import pytest</div>
                    <div bgcolor="#FFFFFF" text="#000000" class="m_-5885689400719985585gmail_msg">

                       

                      skip_A = pytest.mark.skipif(

                          A(pytest.config.request),

                          reason="need --A option to run"

                      )

                      

                      

                    </div>
                    <div bgcolor="#FFFFFF" text="#000000" class="m_-5885689400719985585gmail_msg"> $ py.test testscript.py 

                      ============================= test session starts
                      ==============================

                      platform linux2 -- Python 2.7.12, pytest-2.8.7,
                      py-1.4.31, pluggy-0.3.1

                      rootdir: /home/rjl/pytest, inifile: 

                      collected 0 items / 1 errors 

                      

                      ==============================<wbr>====== ERRORS
                      ==============================<wbr>======

                      ________________________ ERROR collecting
                      testscript.py ________________________

                      testscript.py:4: in &lt;module&gt;

                          A(pytest.config.request),</div>
                    <div bgcolor="#FFFFFF" text="#000000" class="m_-5885689400719985585gmail_msg">

                      E   NameError: name 'A' is not defined

                    </div>
                    <div bgcolor="#FFFFFF" text="#000000" class="m_-5885689400719985585gmail_msg"> =========================== 1
                      error in 0.01 seconds ============================

                      <span class="m_-5885689400719985585m_-3825917875471976212m_-5505830640466454722m_-779162668504465045n m_-5885689400719985585gmail_msg">

                        Instead of doing </span>

                      <span class="m_-5885689400719985585m_-3825917875471976212m_-5505830640466454722m_-779162668504465045n m_-5885689400719985585gmail_msg"><span class="m_-5885689400719985585m_-3825917875471976212m_-5505830640466454722m_-779162668504465045n m_-5885689400719985585gmail_msg">pytest</span><span class="m_-5885689400719985585m_-3825917875471976212m_-5505830640466454722m_-779162668504465045o m_-5885689400719985585gmail_msg">.</span><span class="m_-5885689400719985585m_-3825917875471976212m_-5505830640466454722m_-779162668504465045n m_-5885689400719985585gmail_msg">config</span><span class="m_-5885689400719985585m_-3825917875471976212m_-5505830640466454722m_-779162668504465045o m_-5885689400719985585gmail_msg">.</span><span class="m_-5885689400719985585m_-3825917875471976212m_-5505830640466454722m_-779162668504465045n m_-5885689400719985585gmail_msg">getoption</span><span class="m_-5885689400719985585m_-3825917875471976212m_-5505830640466454722m_-779162668504465045p m_-5885689400719985585gmail_msg"></span> more than one like this:

                        skip_A</span> <span class="m_-5885689400719985585m_-3825917875471976212m_-5505830640466454722m_-779162668504465045o m_-5885689400719985585gmail_msg">=</span> <span class="m_-5885689400719985585m_-3825917875471976212m_-5505830640466454722m_-779162668504465045n m_-5885689400719985585gmail_msg">pytest</span><span class="m_-5885689400719985585m_-3825917875471976212m_-5505830640466454722m_-779162668504465045o m_-5885689400719985585gmail_msg">.</span><span class="m_-5885689400719985585m_-3825917875471976212m_-5505830640466454722m_-779162668504465045n m_-5885689400719985585gmail_msg">mark</span><span class="m_-5885689400719985585m_-3825917875471976212m_-5505830640466454722m_-779162668504465045o m_-5885689400719985585gmail_msg">.</span><span class="m_-5885689400719985585m_-3825917875471976212m_-5505830640466454722m_-779162668504465045n m_-5885689400719985585gmail_msg">skipif</span><span class="m_-5885689400719985585m_-3825917875471976212m_-5505830640466454722m_-779162668504465045p m_-5885689400719985585gmail_msg">(</span> <span class="m_-5885689400719985585m_-3825917875471976212m_-5505830640466454722m_-779162668504465045n m_-5885689400719985585gmail_msg">pytest</span><span class="m_-5885689400719985585m_-3825917875471976212m_-5505830640466454722m_-779162668504465045o m_-5885689400719985585gmail_msg">.</span><span class="m_-5885689400719985585m_-3825917875471976212m_-5505830640466454722m_-779162668504465045n m_-5885689400719985585gmail_msg">config</span><span class="m_-5885689400719985585m_-3825917875471976212m_-5505830640466454722m_-779162668504465045o m_-5885689400719985585gmail_msg">.</span><span class="m_-5885689400719985585m_-3825917875471976212m_-5505830640466454722m_-779162668504465045n m_-5885689400719985585gmail_msg">getoption</span><span class="m_-5885689400719985585m_-3825917875471976212m_-5505830640466454722m_-779162668504465045p m_-5885689400719985585gmail_msg">(</span><span class="m_-5885689400719985585m_-3825917875471976212m_-5505830640466454722m_-779162668504465045s2 m_-5885689400719985585gmail_msg">"--A"</span><span class="m_-5885689400719985585m_-3825917875471976212m_-5505830640466454722m_-779162668504465045p m_-5885689400719985585gmail_msg">)<wbr>,</span> <span class="m_-5885689400719985585m_-3825917875471976212m_-5505830640466454722m_-779162668504465045n m_-5885689400719985585gmail_msg">reason</span><span class="m_-5885689400719985585m_-3825917875471976212m_-5505830640466454722m_-779162668504465045o m_-5885689400719985585gmail_msg">=</span><span class="m_-5885689400719985585m_-3825917875471976212m_-5505830640466454722m_-779162668504465045s2 m_-5885689400719985585gmail_msg">"need --A option to run"</span> <span class="m_-5885689400719985585m_-3825917875471976212m_-5505830640466454722m_-779162668504465045p m_-5885689400719985585gmail_msg">)

                        I want to do it once in the config file.</span>

                      I might want to use the value of the argument --A
                      elsewhere so I don't want to do getoption many
                      times.</div>
                    <div bgcolor="#FFFFFF" text="#000000" class="m_-5885689400719985585gmail_msg">

                      

                      <div class="m_-5885689400719985585m_-3825917875471976212m_-5505830640466454722m_-779162668504465045moz-cite-prefix m_-5885689400719985585gmail_msg">On 2016-10-14 01:16 PM, Bruno
                        Oliveira wrote:

                      </div>
                      <blockquote type="cite" class="m_-5885689400719985585gmail_msg">
                        <div dir="ltr" class="m_-5885689400719985585gmail_msg">
                          <div class="m_-5885689400719985585m_-3825917875471976212m_-5505830640466454722m_-779162668504465045markdown-here-wrapper m_-5885689400719985585gmail_msg">
                            <p style="margin:1.2em 0px!important" class="m_-5885689400719985585gmail_msg">Hi,</p>
                            <p style="margin:1.2em 0px!important" class="m_-5885689400719985585gmail_msg">After fixing the missing
                              “pytest” import, I get this error:</p>
                            <pre style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;margin:1.2em 0px" class="m_-5885689400719985585gmail_msg"><code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline;white-space:pre-wrap;overflow:auto;border-radius:3px;border:1px solid rgb(204,204,204);padding:0.5em 0.7em;display:block!important" class="m_-5885689400719985585gmail_msg">foo.py:8: in &lt;module&gt;
    A(pytest.config.request),
E   AttributeError: 'Config' object has no attribute 'request'
</code></pre>
                            <p style="margin:1.2em 0px!important" class="m_-5885689400719985585gmail_msg">Please make sure to post
                              a complete example and state clearly what
                              your problem is and what you are trying to
                              accomplish.</p>
                            <p style="margin:1.2em 0px!important" class="m_-5885689400719985585gmail_msg">Cheers,

                              Bruno.</p>
                            <div title="MDH:SGksPGRpdj48YnI+PC9kaXY+PGRpdj5BZnRlciBmaXhpbmcgdGhlIG1pc3NpbmcgInB5dGVzdCIgaW1wb3J0LCBJIGdldCB0aGlzIGVycm9yOjwvZGl2PjxkaXY+PGJyPjwvZGl2PjxkaXY+YGBgPC9kaXY+PGRpdj48ZGl2PmZvby5weTo4OiBpbiAmbHQ7bW9kdWxlJmd0OzwvZGl2PjxkaXY+Jm5ic3A7ICZuYnNwOyBBKHB5dGVzdC5jb25maWcucmVxdWVzdCksPC9kaXY+PGRpdj5FICZuYnNwOyBBdHRy
aWJ1dGVFcnJvcjogJ0NvbmZpZycgb2JqZWN0IGhhcyBubyBhdHRyaWJ1dGUgJ3JlcXVlc3QnPC9k
aXY+PC9kaXY+PGRpdj5gYGA8L2Rpdj48ZGl2Pjxicj48L2Rpdj48ZGl2PlBsZWFzZSBtYWtlIHN1
cmUgdG8gcG9zdCBhIGNvbXBsZXRlIGV4YW1wbGUgYW5kIHN0YXRlIGNsZWFybHkgd2hhdCB5b3Vy
IHByb2JsZW0gaXMgYW5kIHdoYXQgeW91IGFyZSB0cnlpbmcgdG8gYWNjb21wbGlzaC48L2Rpdj48
ZGl2Pjxicj48L2Rpdj48ZGl2PkNoZWVycyw8L2Rpdj48ZGl2PkJydW5vLjwvZGl2Pg==" style="min-height:0;width:0;max-height:0;max-width:0;overflow:hidden;font-size:0em;padding:0;margin:0" class="m_-5885689400719985585gmail_msg">​</div>
                          </div>
                        </div>
                        

                        <div class="gmail_quote m_-5885689400719985585gmail_msg">
                          <div dir="ltr" class="m_-5885689400719985585gmail_msg">On Fri, Oct
                            14, 2016 at 2:03 PM James &lt;<a moz-do-not-send="true" href="mailto:bjlockie@lockie.ca" class="m_-5885689400719985585gmail_msg" target="_blank">bjlockie@lockie.ca</a>&gt;
                            wrote:

                          </div>
                          <blockquote class="gmail_quote m_-5885689400719985585gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
                            <div bgcolor="#FFFFFF" text="#000000" class="m_-5885689400719985585gmail_msg">
                              <div class="m_-5885689400719985585m_-3825917875471976212m_-5505830640466454722m_-779162668504465045m_2364392736954871010moz-text-html m_-5885689400719985585gmail_msg" lang="x-western">
                                <div class="m_-5885689400719985585m_-3825917875471976212m_-5505830640466454722m_-779162668504465045m_2364392736954871010WordSection1 m_-5885689400719985585gmail_msg">I have this in my config
                                  file:

                                  @pytest.fixture(scope='module'<wbr>)

                                  def A(request):

                                      return
                                  request.config.getoption("--A"<wbr>)

                                   

                                  skip_A = pytest.mark.skipif(

                                      A(pytest.config.request),

                                      reason="need --A option to run"

                                  )

                                  

                                  but when I run it, it says 

                                  E   NameError: name 'A' is not defined

                                   

                                </div>
                              </div>
                            </div>
______________________________<wbr>_________________

                            testing-in-python mailing list

                            <a moz-do-not-send="true" href="mailto:testing-in-python@lists.idyll.org" class="m_-5885689400719985585gmail_msg" target="_blank">testing-in-python@lists.idyll.<wbr>org</a>

                            <a moz-do-not-send="true" href="http://lists.idyll.org/listinfo/testing-in-python" rel="noreferrer" class="m_-5885689400719985585gmail_msg" target="_blank">http://lists.idyll.org/<wbr>listinfo/testing-in-python</a>

                          </blockquote>
                        </div>
                      </blockquote>
                      

                    </div>
                  </blockquote>
                </div>
              </div>
            </blockquote>
            

          </div>
        </blockquote>
      </div>
    </blockquote>
    

  </div>


______________________________<wbr>_________________

testing-in-python mailing list

<a moz-do-not-send="true" href="mailto:testing-in-python@lists.idyll.org">testing-in-python@lists.idyll.<wbr>org</a>

<a moz-do-not-send="true" href="http://lists.idyll.org/listinfo/testing-in-python" rel="noreferrer" target="_blank">http://lists.idyll.org/<wbr>listinfo/testing-in-python</a>


</blockquote></div>
</div></div></div>


<fieldset class="mimeAttachmentHeader"></fieldset>
<pre wrap="">_______________________________________________
testing-in-python mailing list
<a class="moz-txt-link-abbreviated" href="mailto:testing-in-python@lists.idyll.org">testing-in-python@lists.idyll.org</a>
<a class="moz-txt-link-freetext" href="http://lists.idyll.org/listinfo/testing-in-python">http://lists.idyll.org/listinfo/testing-in-python</a>
</pre>

</blockquote>
</body></html>