* [gentoo-commits] proj/portage:master commit in: lib/portage/tests/gpkg/
@ 2024-02-09 23:18 Zac Medico
0 siblings, 0 replies; 5+ messages in thread
From: Zac Medico @ 2024-02-09 23:18 UTC (permalink / raw
To: gentoo-commits
commit: 3dac4f892479d6215c378f761505ab3d41a4b3ef
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Fri Feb 9 23:18:11 2024 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Fri Feb 9 23:18:26 2024 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=3dac4f89
test_gpkg_path_case: Add missing playground cleanup
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>
lib/portage/tests/gpkg/test_gpkg_path.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/portage/tests/gpkg/test_gpkg_path.py b/lib/portage/tests/gpkg/test_gpkg_path.py
index fc57135949..19451e2e9b 100644
--- a/lib/portage/tests/gpkg/test_gpkg_path.py
+++ b/lib/portage/tests/gpkg/test_gpkg_path.py
@@ -1,4 +1,4 @@
-# Copyright Gentoo Foundation 2006
+# Copyright 2022-2024 Gentoo Authors
# Portage Unit Testing Functionality
import tempfile
@@ -308,6 +308,7 @@ class test_gpkg_path_case(TestCase):
self.assertEqual(r, ())
finally:
shutil.rmtree(tmpdir)
+ playground.cleanup()
def test_gpkg_long_filename(self):
playground = ResolverPlayground(
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [gentoo-commits] proj/portage:master commit in: lib/portage/tests/gpkg/
@ 2024-02-10 20:27 Zac Medico
0 siblings, 0 replies; 5+ messages in thread
From: Zac Medico @ 2024-02-10 20:27 UTC (permalink / raw
To: gentoo-commits
commit: d320211266b95dc8cbea295cb234a607246d955f
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat Feb 10 20:25:28 2024 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Feb 10 20:26:17 2024 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=d3202112
test_gpkg_metadata_url_case: shutdown http server daemon threads
Bug: https://bugs.gentoo.org/924192
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>
lib/portage/tests/gpkg/test_gpkg_metadata_url.py | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/lib/portage/tests/gpkg/test_gpkg_metadata_url.py b/lib/portage/tests/gpkg/test_gpkg_metadata_url.py
index 857defe188..422ca7d3fa 100644
--- a/lib/portage/tests/gpkg/test_gpkg_metadata_url.py
+++ b/lib/portage/tests/gpkg/test_gpkg_metadata_url.py
@@ -7,6 +7,7 @@ import tarfile
import tempfile
from functools import partial
from os import urandom
+from concurrent.futures import Future
from portage.gpkg import gpkg
from portage import os
@@ -18,7 +19,7 @@ from portage.gpg import GPG
class test_gpkg_metadata_url_case(TestCase):
- def httpd(self, directory, port):
+ def httpd(self, directory, port, httpd_future):
try:
import http.server
import socketserver
@@ -28,6 +29,7 @@ class test_gpkg_metadata_url_case(TestCase):
Handler = partial(http.server.SimpleHTTPRequestHandler, directory=directory)
with socketserver.TCPServer(("127.0.0.1", port), Handler) as httpd:
+ httpd_future.set_result(httpd)
httpd.serve_forever()
def start_http_server(self, directory, port):
@@ -36,11 +38,12 @@ class test_gpkg_metadata_url_case(TestCase):
except ImportError:
self.skipTest("threading module not exists")
+ httpd_future = Future()
server = threading.Thread(
- target=self.httpd, args=(directory, port), daemon=True
+ target=self.httpd, args=(directory, port, httpd_future), daemon=True
)
server.start()
- return server
+ return httpd_future.result()
def test_gpkg_get_metadata_url(self):
playground = ResolverPlayground(
@@ -53,6 +56,7 @@ class test_gpkg_metadata_url_case(TestCase):
}
)
tmpdir = tempfile.mkdtemp()
+ server = None
try:
settings = playground.settings
for _ in range(0, 5):
@@ -85,6 +89,8 @@ class test_gpkg_metadata_url_case(TestCase):
self.assertEqual(meta, meta_from_url)
finally:
+ if server is not None:
+ server.shutdown()
shutil.rmtree(tmpdir)
playground.cleanup()
@@ -99,6 +105,7 @@ class test_gpkg_metadata_url_case(TestCase):
)
tmpdir = tempfile.mkdtemp()
gpg = None
+ server = None
try:
settings = playground.settings
gpg = GPG(settings)
@@ -159,5 +166,7 @@ IkCfAP49AOYjzuQPP0n5P0SGCINnAVEXN7QLQ4PurY/lt7cT2gEAq01stXjFhrz5
finally:
if gpg is not None:
gpg.stop()
+ if server is not None:
+ server.shutdown()
shutil.rmtree(tmpdir)
playground.cleanup()
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [gentoo-commits] proj/portage:master commit in: lib/portage/tests/gpkg/
@ 2024-02-10 20:54 Zac Medico
0 siblings, 0 replies; 5+ messages in thread
From: Zac Medico @ 2024-02-10 20:54 UTC (permalink / raw
To: gentoo-commits
commit: d279a3a5c4907f2ed8c7dc52d9c240ee33a35987
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat Feb 10 20:41:01 2024 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Feb 10 20:50:38 2024 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=d279a3a5
test_gpkg_metadata_url_case: optimize httpd port allocation
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>
lib/portage/tests/gpkg/test_gpkg_metadata_url.py | 28 +++++++-----------------
1 file changed, 8 insertions(+), 20 deletions(-)
diff --git a/lib/portage/tests/gpkg/test_gpkg_metadata_url.py b/lib/portage/tests/gpkg/test_gpkg_metadata_url.py
index 422ca7d3fa..271d3e4d5f 100644
--- a/lib/portage/tests/gpkg/test_gpkg_metadata_url.py
+++ b/lib/portage/tests/gpkg/test_gpkg_metadata_url.py
@@ -19,7 +19,7 @@ from portage.gpg import GPG
class test_gpkg_metadata_url_case(TestCase):
- def httpd(self, directory, port, httpd_future):
+ def httpd(self, directory, httpd_future):
try:
import http.server
import socketserver
@@ -28,11 +28,11 @@ class test_gpkg_metadata_url_case(TestCase):
Handler = partial(http.server.SimpleHTTPRequestHandler, directory=directory)
- with socketserver.TCPServer(("127.0.0.1", port), Handler) as httpd:
+ with socketserver.TCPServer(("127.0.0.1", 0), Handler) as httpd:
httpd_future.set_result(httpd)
httpd.serve_forever()
- def start_http_server(self, directory, port):
+ def start_http_server(self, directory):
try:
import threading
except ImportError:
@@ -40,7 +40,7 @@ class test_gpkg_metadata_url_case(TestCase):
httpd_future = Future()
server = threading.Thread(
- target=self.httpd, args=(directory, port, httpd_future), daemon=True
+ target=self.httpd, args=(directory, httpd_future), daemon=True
)
server.start()
return httpd_future.result()
@@ -59,13 +59,7 @@ class test_gpkg_metadata_url_case(TestCase):
server = None
try:
settings = playground.settings
- for _ in range(0, 5):
- port = random.randint(30000, 60000)
- try:
- server = self.start_http_server(tmpdir, port)
- except OSError:
- continue
- break
+ server = self.start_http_server(tmpdir)
orig_full_path = os.path.join(tmpdir, "orig/")
os.makedirs(orig_full_path)
@@ -84,7 +78,7 @@ class test_gpkg_metadata_url_case(TestCase):
test_gpkg.compress(os.path.join(tmpdir, "orig"), meta)
meta_from_url = test_gpkg.get_metadata_url(
- "http://127.0.0.1:" + str(port) + "/test.gpkg.tar"
+ "http://{0}:{1}/test.gpkg.tar".format(*server.server_address)
)
self.assertEqual(meta, meta_from_url)
@@ -111,13 +105,7 @@ class test_gpkg_metadata_url_case(TestCase):
gpg = GPG(settings)
gpg.unlock()
- for _ in range(0, 5):
- port = random.randint(30000, 60000)
- try:
- server = self.start_http_server(tmpdir, port)
- except OSError:
- continue
- break
+ server = self.start_http_server(tmpdir)
orig_full_path = os.path.join(tmpdir, "orig/")
os.makedirs(orig_full_path)
@@ -161,7 +149,7 @@ IkCfAP49AOYjzuQPP0n5P0SGCINnAVEXN7QLQ4PurY/lt7cT2gEAq01stXjFhrz5
self.assertRaises(
InvalidSignature,
test_gpkg.get_metadata_url,
- "http://127.0.0.1:" + str(port) + "/test-2.gpkg.tar",
+ "http://{0}:{1}/test-2.gpkg.tar".format(*server.server_address),
)
finally:
if gpg is not None:
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [gentoo-commits] proj/portage:master commit in: lib/portage/tests/gpkg/
@ 2024-02-10 21:02 Zac Medico
0 siblings, 0 replies; 5+ messages in thread
From: Zac Medico @ 2024-02-10 21:02 UTC (permalink / raw
To: gentoo-commits
commit: 9100b425a38f0f0631a4377da82f421ad87546b4
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat Feb 10 21:01:17 2024 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Feb 10 21:02:13 2024 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=9100b425
test_gpkg_metadata_url_case: fix pylint W0611: Unused import random (unused-import)
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>
lib/portage/tests/gpkg/test_gpkg_metadata_url.py | 1 -
1 file changed, 1 deletion(-)
diff --git a/lib/portage/tests/gpkg/test_gpkg_metadata_url.py b/lib/portage/tests/gpkg/test_gpkg_metadata_url.py
index 271d3e4d5f..3773049227 100644
--- a/lib/portage/tests/gpkg/test_gpkg_metadata_url.py
+++ b/lib/portage/tests/gpkg/test_gpkg_metadata_url.py
@@ -2,7 +2,6 @@
# Portage Unit Testing Functionality
import io
-import random
import tarfile
import tempfile
from functools import partial
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [gentoo-commits] proj/portage:master commit in: lib/portage/tests/gpkg/
@ 2024-02-11 4:33 Zac Medico
0 siblings, 0 replies; 5+ messages in thread
From: Zac Medico @ 2024-02-11 4:33 UTC (permalink / raw
To: gentoo-commits
commit: e02feddd148f4a4a5854edd81b9aa67844d8956f
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun Feb 11 04:31:41 2024 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun Feb 11 04:32:27 2024 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=e02feddd
test_gpkg_metadata_url_case: fix string format for pyupgrade
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>
lib/portage/tests/gpkg/test_gpkg_metadata_url.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/portage/tests/gpkg/test_gpkg_metadata_url.py b/lib/portage/tests/gpkg/test_gpkg_metadata_url.py
index 3773049227..e9f4111279 100644
--- a/lib/portage/tests/gpkg/test_gpkg_metadata_url.py
+++ b/lib/portage/tests/gpkg/test_gpkg_metadata_url.py
@@ -77,7 +77,7 @@ class test_gpkg_metadata_url_case(TestCase):
test_gpkg.compress(os.path.join(tmpdir, "orig"), meta)
meta_from_url = test_gpkg.get_metadata_url(
- "http://{0}:{1}/test.gpkg.tar".format(*server.server_address)
+ "http://{}:{}/test.gpkg.tar".format(*server.server_address)
)
self.assertEqual(meta, meta_from_url)
@@ -148,7 +148,7 @@ IkCfAP49AOYjzuQPP0n5P0SGCINnAVEXN7QLQ4PurY/lt7cT2gEAq01stXjFhrz5
self.assertRaises(
InvalidSignature,
test_gpkg.get_metadata_url,
- "http://{0}:{1}/test-2.gpkg.tar".format(*server.server_address),
+ "http://{}:{}/test-2.gpkg.tar".format(*server.server_address),
)
finally:
if gpg is not None:
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-02-11 4:33 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-10 20:27 [gentoo-commits] proj/portage:master commit in: lib/portage/tests/gpkg/ Zac Medico
-- strict thread matches above, loose matches on Subject: below --
2024-02-11 4:33 Zac Medico
2024-02-10 21:02 Zac Medico
2024-02-10 20:54 Zac Medico
2024-02-09 23:18 Zac Medico
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox