Skip to content

Commit 1d68fbd

Browse files
tests/test_logger.py: Use pyfakefs: don't create a file in the host
Signed-off-by: Bernhard Kaindl <bernhard.kaindl@cloud.com>
1 parent f531be6 commit 1d68fbd

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

tests/test_logger.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,16 @@
1010
from xcp.logger import openLog
1111

1212

13-
def test_openLog_mock_open():
14-
"""Cover xcp.logger.openLog.open_with_codec_handling and check the arguments used for open()"""
13+
def test_openLog_mock_open(fs):
14+
# type(FakeFilesystem) -> None
15+
"""
16+
- Covers xcp.logger.openLog.open_with_codec_handling and
17+
- checks the arguments it uses for open()
18+
19+
Because needs to call openLog() which creates a logfile, this test uses
20+
the pytest pyfakefs fixture 'fs' which wraps creating it in a virtual fs.
21+
With it, this tests does not create a log file on the filesystem of the host.
22+
"""
1523
fh = StringIO()
1624
with patch("xcp.compat.open", mock_open()) as open_mock:
1725
open_mock.return_value = fh

0 commit comments

Comments
 (0)