title: Run a test with two different pytest fixtures
body: <p>I am currently testing a web app using pytest and Selenium. All pages have "Home" and "Log Out" links, so I have written a test like this:</p>
  
  <pre><code>def test_can_log_out(page):
      link = page.find_element_by_partial_link_text('Log Out')
      link.click()
      assert 'YOU HAVE SUCCESSFULLY LOGGED OFF!' in starting_page.page_source
  </code></pre>
  
  <p>Now for the <code>page</code> fixture, I am simulating the login process. I have this broken into several fixtures: </p>
  
  <ol>
  <li><p>Get the Selenium WebDriver instances</p>
  
  <pre><code>@pytest.fixture()
  def browser(request, data, headless):
      b = webdriver.Firefox(executable_path=DRIVERS_PATH + '/geckodriver')
      yield b
      b.quit()
  </code></pre></li>
  <li><p>Log in to the web app</p>
  
  <pre><code>@pytest.fixture()
  def login(browser):
      browser.get('http://example.com/login)
      user_name = browser.find_element_by_name('user_name')
      user_name.send_keys('codeapprentice')
      password = browser.find_element_by_name('password')
      password.send_keys('password1234')
      submit = browser.find_element_by_name('submit')
      submit.click()
      return browser
  </code></pre></li>
  <li><p>Visit a page</p>
  
  <pre><code>@pytest.fixture()
  def page(login):
      link = login.find_element_by_partial_link_text('Sub Page A')
      link.click()
      return login
  </code></pre></li>
  </ol>
  
  <p>This works very well and I can test logging out from this page. Now my question is that I have another page which can be visited from "Page A":</p>
  
  <pre><code>@pytest.fixture()
  def subpage(page):
      button = login.find_element_name('button')
      button.click()
      return page
  </code></pre>
  
  <p>Now I want to run the exact same test with this fixture, also. Of course, I can copy/paste and make a few changes:</p>
  
  <pre><code>def test_can_log_out_subpage(subpage):
      link = page.find_element_by_partial_link_text('Log Out')
      link.click()
      assert 'YOU HAVE SUCCESSFULLY LOGGED OFF!' in starting_page.page_source
  </code></pre>
  
  <p>However, this violates the DRY principle. How can I reuse <code>test_can_log_out()</code> without this repetition?</p>