[New-bugs-announce] [issue37669] Make mock_open return per-file content

Damien Nadé report at bugs.python.org
Wed Jul 24 08:46:58 EDT 2019


New submission from Damien Nadé <bugzilla-python at livna.org>:

Let's say I have a function that opens 2 files and compare them. mock_open would not allow me to test this case, as it would return the same data for both files (through its read_data argument).

I want to be able to do this in a mocked-open context:
```
with open("file1") as file1:
    assert file1.read() == "data1"

with open("file2") as file2:
    assert file2.read() == "data2"
```

----------
components: Library (Lib)
messages: 348386
nosy: Anvil
priority: normal
severity: normal
status: open
title: Make mock_open return per-file content
type: enhancement
versions: Python 3.7, Python 3.8, Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37669>
_______________________________________


More information about the New-bugs-announce mailing list