title: Skip a whole file conditionally with doctest
body: <p>I wrote a sphinx <code>.rst</code> file whith doctest snippets using f-strings. I use tox to test my project and my documentation with several versions of python, and pytest to run the tests with <code>pytest --doctest-glob='*.rst'</code>. Some of the python versions I run the tests on are not supporting f-strings (2.7 and 3.5). I need to skip this file with old python versions.</p>
  
  <p>The <code>:skipif:</code> and <code>:pyversion:</code> in the code blocks are ineffective, and I get the following error when used:</p>
  
  <pre><code>UNEXPECTED EXCEPTION: SyntaxError('invalid syntax', (hello = "hello {foobar} world")'))
  Traceback (most recent call last):
  
    File "/usr/lib64/python3.5/doctest.py", line 1321, in __run
      compileflags, 1), test.mytest)
  
    File "&lt;doctest myfile.rst[1]&gt;", line 1
  
      hello = "hello {foobar} world"
                                   ^
  SyntaxError: invalid syntax
  myfile.rst:26: UnexpectedException
  </code></pre>
  
  <p>The test and the tox configuration are very generic:</p>
  
  <pre><code># setup.cfg
  [tox:tox]
  envlist=py27,py35,py36,py37,py38
  </code></pre>
  
  <p> </p>
  
  <pre><code># myfile.rst
  &gt;&gt;&gt; foobar = "foobar"
  &gt;&gt;&gt; hello = f"hello {foobar} world"
  </code></pre>
  
  <p>How can I prevent the whole file to be tested, or even parsed, without explicitly ignoring it with pytest?</p>