Support Windows 7 with Python 3.8

This commit is contained in:
hz
2026-09-27 14:23:47 -05:00
parent 005ad5a2eb
commit 48500792ce
3 changed files with 34 additions and 3 deletions
+19
View File
@@ -1,6 +1,7 @@
import pathlib
import json
import sys
import subprocess
import tempfile
import threading
import unittest
@@ -11,6 +12,24 @@ from network_monitor import Detector, analyze_trace, parse_ping, parse_trace, ru
class MonitorTests(unittest.TestCase):
@unittest.skipUnless(sys.platform == "win32", "requires Windows ping and tracert")
def test_main_finishes_diagnostic_and_closes_log(self):
# Exercise real executor shutdown on the interpreter running the suite,
# including Python 3.8, where cancel_futures is unavailable.
with tempfile.TemporaryDirectory() as directory:
result = subprocess.run(
[sys.executable, str(pathlib.Path(__file__).with_name("network_monitor.py")),
"--target", "127.0.0.1", "--count", "1", "--trace-now",
"--log-dir", directory],
stdout=subprocess.PIPE, stderr=subprocess.STDOUT, timeout=20)
self.assertEqual(result.returncode, 0, result.stdout.decode(errors="replace"))
entries = [json.loads(line) for line in
(pathlib.Path(directory) / "events.jsonl").read_text().splitlines()]
self.assertEqual(entries[-1]["event"], "stop")
self.assertEqual(entries[-1]["samples"], 1)
self.assertTrue(any(entry["event"] == "trace_complete" for entry in entries))
self.assertFalse(any(entry["event"] == "error" for entry in entries))
def test_only_bad_pings_are_logged(self):
with tempfile.TemporaryDirectory() as directory:
log = Log(pathlib.Path(directory))