projects/guix·blob ruby-team · refs

58 lines · 2.1 KiB

1Do not leave open files behind as this triggers 'ResourceWarning' and leads
2these tests to fail.
3
4--- Werkzeug-1.0.1/tests/test_datastructures.py 2020-03-31 19:48:06.000000000 +0200
5+++ Werkzeug-1.0.1/tests/test_datastructures.py 2021-11-21 18:19:11.304369878 +0100
6@@ -1238,9 +1238,10 @@
7 def test_save_to_pathlib_dst(self, tmp_path):
8 src = tmp_path / "src.txt"
9 src.write_text(u"test")
10- storage = self.storage_class(src.open("rb"))
11- dst = tmp_path / "dst.txt"
12- storage.save(dst)
13+ with src.open("rb") as input:
14+ storage = self.storage_class(input)
15+ dst = tmp_path / "dst.txt"
16+ storage.save(dst)
17 assert dst.read_text() == "test"
18
19 def test_save_to_bytes_io(self):
20@@ -1251,11 +1252,12 @@
21
22 def test_save_to_file(self, tmp_path):
23 path = tmp_path / "file.data"
24- storage = self.storage_class(io.BytesIO(b"one\ntwo"))
25- with path.open("wb") as dst:
26- storage.save(dst)
27- with path.open("rb") as src:
28- assert src.read() == b"one\ntwo"
29+ with io.BytesIO(b"one\ntwo") as input:
30+ storage = self.storage_class(input)
31+ with path.open("wb") as dst:
32+ storage.save(dst)
33+ with path.open("rb") as src:
34+ assert src.read() == b"one\ntwo"
35
36
37 @pytest.mark.parametrize("ranges", ([(0, 1), (-5, None)], [(5, None)]))
38--- Werkzeug-1.0.1/tests/test_formparser.py 2020-03-31 19:48:06.000000000 +0200
39+++ Werkzeug-1.0.1/tests/test_formparser.py 2021-11-21 22:11:43.654622751 +0100
40@@ -27,7 +27,7 @@
41 from werkzeug.test import create_environ
42 from werkzeug.wrappers import Request
43 from werkzeug.wrappers import Response
44-
45+import warnings
46
47 @Request.application
48 def form_data_consumer(request):
49@@ -242,6 +244,9 @@
50
51 class TestMultiPart(object):
52 def test_basic(self):
53+ # Ignore leaked file descriptor of unknown origin.
54+ warnings.filterwarnings(action="ignore", message="unclosed", category=ResourceWarning)
55+
56 resources = join(dirname(__file__), "multipart")
57 client = Client(form_data_consumer, Response)
58