How do I use pytest to check that two different files in the same function are opened correctly?

**open\_two\_files.py**

```
def open_two_files(input_filepath, output_filepath):
    open_output = open(output_filepath, 'w')
    with open(input_filepath, 'r') as open_input:
      for line in open_input:
        open_output.write('foo')

```

I used [this answer](https://stackoverflow.com/a/55657579/7222588) to build a test

**test\_open\_two\_files.py**

```
import pytest
from unittest.mock import patch, mock_open
from open_two_files import *

def test_open_two_files():
    open_mock = mock_open()
    with patch('open_two_files.open', open_mock, create=True):
        open_two_files("input_filepath", "output_filepath")
    open_mock.assert_called_with("input_filepath", 'r')
    # pytest passes with the following line commented out
    open_mock.assert_called_with("output_filepath", 'w')

```

The error I get is

```
E           AssertionError: expected call not found.
E           Expected: open('output_filepath', 'w')
E           Actual: open('input_filepath', 'r')

```

If I comment out the last line, the tests pass. The testing seems to only look at the last time that a file is opened. How do I test all occurrences of a file being opened please?