title: Passing pytest fixtures to non-pytest code
body: <p>When <code>f.result</code> is called normally, it returns <code>1</code>.  However when I test <code>f</code>, I want to pass the return value of fixture <code>my_var</code> to <code>f</code> so the <code>assert</code> in <code>test_stuff</code> returns <code>True</code>.</p>
  <p>Is there a pytest feature that will facilitate this?</p>
  <pre><code># conftest.py
  import pytest
  @pytest.fixture()
  def my_var():
    b = 2
    return b
  </code></pre>
  <pre><code># test_stuff.py
  import pytest
  from mycode import f
  
  def test_stuff():
    assert f.result == 2
  
  
  &quot;&quot;&quot;
  ./tests/test_stuff.py::test_stuff Failed: [undefined]assert 1 == 2
   +  where 1 = f.result
  def test_stuff():
  &gt;     assert f.result == 2
  E     assert 1 == 2
  E      +  where 1 = f.result
  
  tests/test_stuff.py:5: AssertionError
  &quot;&quot;&quot;
  </code></pre>
  <pre><code># mycode.py
  class f:
    
    ## Pytest fixture to cast b as my_var here?
    def thing(a: int, b: int = None) -&gt; int:
      ## Or maybe a way to cast b as my_var here?
      if not b:
        return a
      else:
        return b
  
    result = thing(1)
  
  if __name__ == &quot;__main__&quot;:
    print(f.result)
  </code></pre>