title: When to use pytest fixtures?
body: <p>I'm new to testing and I've stumbled across pytest fixtures, but I'm not entirely sure when to use them and why they're useful. </p>
  
  <p>For example, see the below code: </p>
  
  <pre><code>import pytest
  
  @pytest.fixture
  def input_value():
     input = 39
     return input
  
  def test_divisible_by_3(input_value):
     assert input_value % 3 == 0
  
  def test_divisible_by_6(input_value):
     assert input_value % 6 == 0
  </code></pre>
  
  <p>What is the function of the pytest.fixture here? Why can't we simply create a function called <code>input_value()</code> and run that function inside of the test function? For example: </p>
  
  <pre><code>import pytest
  
  def input_value():
     input = 39
     return input
  
  def test_divisible_by_3():
     assert input_value() % 3 == 0
  
  def test_divisible_by_6():
     assert input_value() % 6 == 0
  </code></pre>
  
  <p>Why can't we just do this? What's the use of using fixtures?</p>