From a183837ec8bb5e28fe6eb3a9d77ea2d0d7a106bd Mon Sep 17 00:00:00 2001 From: bashonly <88596187+bashonly@users.noreply.github.com> Date: Sun, 7 Sep 2025 15:43:39 -0500 Subject: [PATCH] [test:utils] Fix `sanitize_path` test for Windows CPython 3.11 (#13878) Authored by: Grub4K Co-authored-by: Simon Sawicki --- test/test_utils.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/test/test_utils.py b/test/test_utils.py index 9e70ad480..83916b46d 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -12,6 +12,7 @@ import datetime as dt import io import itertools import json +import ntpath import pickle import subprocess import unittest @@ -253,12 +254,6 @@ class TestUtil(unittest.TestCase): self.assertEqual(sanitize_path('abc.../def...'), 'abc..#\\def..#') self.assertEqual(sanitize_path('C:\\abc:%(title)s.%(ext)s'), 'C:\\abc#%(title)s.%(ext)s') - # Check with nt._path_normpath if available - try: - from nt import _path_normpath as nt_path_normpath - except ImportError: - nt_path_normpath = None - for test, expected in [ ('C:\\', 'C:\\'), ('../abc', '..\\abc'), @@ -276,8 +271,7 @@ class TestUtil(unittest.TestCase): result = sanitize_path(test) assert result == expected, f'{test} was incorrectly resolved' assert result == sanitize_path(result), f'{test} changed after sanitizing again' - if nt_path_normpath: - assert result == nt_path_normpath(test), f'{test} does not match nt._path_normpath' + assert result == ntpath.normpath(test), f'{test} does not match ntpath.normpath' def test_sanitize_url(self): self.assertEqual(sanitize_url('//foo.bar'), 'http://foo.bar')