1
0
Fork 0
mirror of https://gitlab.alpinelinux.org/alpine/aports.git synced 2025-07-20 09:45:12 +03:00
aports/testing/py3-podman/fix-tests.patch
2021-12-30 01:34:28 +01:00

39 lines
1.6 KiB
Diff

Patch-Source: https://github.com/containers/podman-py/pull/154
From d1f4a6a0c095c3b9665c4f4d2fa492036094db80 Mon Sep 17 00:00:00 2001
From: "Jonathan G. Underwood" <jonathan.underwood@gmail.com>
Date: Sun, 26 Dec 2021 19:17:07 +0000
Subject: [PATCH] Fix incorrect patching of open() in tests
The tests for prepare_containerignore incorrectly patch the io.open()
function. Since prepare_containerignore calls the open instance method
on a pathlib.Path object, we patch pathlib.Path.open() instead.
Patching io.open() worked when the tests were run under nose, but not
under pytest. With this change the tests work under both.
---
podman/tests/unit/test_api_utils.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/podman/tests/unit/test_api_utils.py b/podman/tests/unit/test_api_utils.py
index 321c2cf..6867df8 100644
--- a/podman/tests/unit/test_api_utils.py
+++ b/podman/tests/unit/test_api_utils.py
@@ -65,7 +65,7 @@ def test_containerignore_read(self, patch_exists):
**/*.class
"""
- with mock.patch("io.open", mock_open(read_data=data)):
+ with mock.patch("pathlib.Path.open", mock_open(read_data=data)):
actual = api.prepare_containerignore(".")
self.assertListEqual(
@@ -79,7 +79,7 @@ def test_containerignore_empty(self, patch_exists):
"""
patch_exists.return_value = True
- with mock.patch("io.open", mock_open(read_data=data)):
+ with mock.patch("pathlib.Path.open", mock_open(read_data=data)):
actual = api.prepare_containerignore(".")
self.assertListEqual(actual, [])