tests: alphabetize and group Python imports & add check

- De-duplicates, groups, and sorts imports based on the provided `isort` settings.
This commit is contained in:
Dan Fandrich 2026-04-03 11:52:44 -07:00
parent 4c1b6f5494
commit 98e470b3a8
44 changed files with 110 additions and 134 deletions

View file

@ -29,5 +29,5 @@
ruff check --extend-select=B007,B016,C405,C416,COM818,D200,D213,D204,D401,\
D415,FURB129,N818,PERF401,PERF403,PIE790,PIE808,PLW0127,Q004,RUF010,SIM101,\
SIM117,SIM118,TRY400,TRY401,RET503,RET504,UP004,B018,B904,RSE102,RET505 \
SIM117,SIM118,TRY400,TRY401,RET503,RET504,UP004,B018,B904,RSE102,RET505,I001 \
"$@"

View file

@ -26,8 +26,7 @@
#
"""DICT server."""
from __future__ import (absolute_import, division, print_function,
unicode_literals)
from __future__ import absolute_import, division, print_function, unicode_literals
import argparse
import logging

View file

@ -24,17 +24,16 @@
#
import logging
import os
import sys
import platform
import sys
from typing import Generator, Union
import pytest
from testenv.env import EnvConfig
sys.path.append(os.path.join(os.path.dirname(__file__), '.'))
from testenv import Env, Nghttpx, Httpd, NghttpxQuic, NghttpxFwd, Sshd
from testenv import Env, Httpd, Nghttpx, NghttpxFwd, NghttpxQuic, Sshd
log = logging.getLogger(__name__)

View file

@ -32,9 +32,18 @@ import os
import re
import sys
from statistics import mean
from typing import Dict, Any, Optional, List
from typing import Any, Dict, List, Optional
from testenv import Env, Httpd, CurlClient, Caddy, ExecResult, NghttpxQuic, RunProfile, Dante
from testenv import (
Caddy,
CurlClient,
Dante,
Env,
ExecResult,
Httpd,
NghttpxQuic,
RunProfile,
)
log = logging.getLogger(__name__)

View file

@ -26,11 +26,9 @@
#
import logging
import re
import pytest
from testenv import Env
from testenv import CurlClient
from testenv import CurlClient, Env
log = logging.getLogger(__name__)

View file

@ -30,10 +30,9 @@ import logging
import os
import re
import sys
import pytest
from testenv import Env, CurlClient, LocalClient
from testenv import CurlClient, Env, LocalClient
log = logging.getLogger(__name__)

View file

@ -28,10 +28,9 @@ import logging
import time
from datetime import timedelta
from threading import Thread
import pytest
from testenv import Env, CurlClient, ExecResult
from testenv import CurlClient, Env, ExecResult
log = logging.getLogger(__name__)

View file

@ -25,11 +25,10 @@
###########################################################################
#
import logging
from typing import Tuple, List, Dict
from typing import Dict, List, Tuple
import pytest
from testenv import Env, CurlClient
from testenv import CurlClient, Env
log = logging.getLogger(__name__)

View file

@ -26,10 +26,9 @@
#
import logging
import os
import pytest
from testenv import Env, CurlClient
from testenv import CurlClient, Env
log = logging.getLogger(__name__)

View file

@ -26,10 +26,9 @@
#
import logging
import re
import pytest
from testenv import Env, CurlClient
from testenv import CurlClient, Env
log = logging.getLogger(__name__)

View file

@ -30,11 +30,10 @@ import logging
import os
import re
import sys
import pytest
from typing import List, Union
from testenv import Env, CurlClient, LocalClient, ExecResult
import pytest
from testenv import CurlClient, Env, ExecResult, LocalClient
log = logging.getLogger(__name__)

View file

@ -29,10 +29,9 @@ import filecmp
import logging
import os
import re
import pytest
from testenv import Env, CurlClient, Caddy, LocalClient
from testenv import Caddy, CurlClient, Env, LocalClient
log = logging.getLogger(__name__)

View file

@ -26,10 +26,9 @@
#
import logging
import os
import pytest
from testenv import Env, CurlClient, LocalClient
from testenv import CurlClient, Env, LocalClient
log = logging.getLogger(__name__)

View file

@ -29,10 +29,9 @@ import logging
import os
import re
import sys
import pytest
from testenv import Env, CurlClient, ExecResult
from testenv import CurlClient, Env, ExecResult
log = logging.getLogger(__name__)

View file

@ -31,9 +31,7 @@ from threading import Thread
from typing import Generator
import pytest
from testenv import Env, CurlClient
from testenv import CurlClient, Env
log = logging.getLogger(__name__)

View file

@ -25,10 +25,9 @@
###########################################################################
#
import logging
import pytest
from testenv import Env, CurlClient
from testenv import CurlClient, Env
log = logging.getLogger(__name__)

View file

@ -27,10 +27,9 @@
import logging
import os
import re
import pytest
from testenv import Env, CurlClient, ExecResult
from testenv import CurlClient, Env, ExecResult
log = logging.getLogger(__name__)

View file

@ -26,10 +26,9 @@
#
import logging
import os
import pytest
from testenv import Env, CurlClient
from testenv import CurlClient, Env
log = logging.getLogger(__name__)

View file

@ -26,11 +26,9 @@
#
import logging
import re
import pytest
from testenv import Env
from testenv import CurlClient
from testenv import CurlClient, Env
log = logging.getLogger(__name__)

View file

@ -26,10 +26,9 @@
#
import logging
import os
import pytest
from testenv import Env, CurlClient
from testenv import CurlClient, Env
log = logging.getLogger(__name__)

View file

@ -28,10 +28,9 @@ import json
import logging
import os
import re
import pytest
from testenv import Env, CurlClient, LocalClient
from testenv import CurlClient, Env, LocalClient
log = logging.getLogger(__name__)

View file

@ -25,10 +25,9 @@
###########################################################################
#
import logging
import pytest
from testenv import Env, CurlClient
from testenv import CurlClient, Env
log = logging.getLogger(__name__)

View file

@ -27,10 +27,9 @@
import logging
import os
import re
import pytest
from testenv import Env, CurlClient, LocalClient
from testenv import CurlClient, Env, LocalClient
log = logging.getLogger(__name__)

View file

@ -32,12 +32,11 @@ import subprocess
import time
from datetime import datetime, timedelta
from typing import Dict
import pytest
from testenv import Env, CurlClient, LocalClient
from testenv import CurlClient, Env, LocalClient
from testenv.ports import alloc_ports_and_do
log = logging.getLogger(__name__)

View file

@ -27,10 +27,9 @@
import logging
import os
from datetime import timedelta
import pytest
from testenv import Env, CurlClient, LocalClient
from testenv import CurlClient, Env, LocalClient
log = logging.getLogger(__name__)

View file

@ -29,10 +29,9 @@ import filecmp
import logging
import os
import shutil
import pytest
from testenv import Env, CurlClient, VsFTPD, LocalClient
from testenv import CurlClient, Env, LocalClient, VsFTPD
log = logging.getLogger(__name__)

View file

@ -29,10 +29,9 @@ import filecmp
import logging
import os
import shutil
import pytest
from testenv import Env, CurlClient, VsFTPD, LocalClient
from testenv import CurlClient, Env, LocalClient, VsFTPD
log = logging.getLogger(__name__)

View file

@ -29,10 +29,9 @@ import filecmp
import logging
import os
import shutil
import pytest
from testenv import Env, CurlClient, VsFTPD, LocalClient
from testenv import CurlClient, Env, LocalClient, VsFTPD
log = logging.getLogger(__name__)

View file

@ -28,10 +28,9 @@ import logging
import os
import time
from typing import Generator
import pytest
from testenv import Env, CurlClient, Dante
from testenv import CurlClient, Dante, Env
log = logging.getLogger(__name__)

View file

@ -28,10 +28,9 @@ import difflib
import filecmp
import logging
import os
import pytest
from testenv import Env, CurlClient, Sshd
from testenv import CurlClient, Env, Sshd
log = logging.getLogger(__name__)

View file

@ -28,10 +28,9 @@ import difflib
import filecmp
import logging
import os
import pytest
from testenv import Env, CurlClient, Sshd
from testenv import CurlClient, Env, Sshd
log = logging.getLogger(__name__)

View file

@ -25,16 +25,19 @@
###########################################################################
# ruff: noqa: F401, E402
import pytest
pytest.register_assert_rewrite("testenv.env", "testenv.curl", "testenv.caddy",
"testenv.httpd", "testenv.nghttpx")
from .env import Env
from .certs import TestCA, Credentials
# This import must be first to avoid circular imports
from .curl import CurlClient, ExecResult, RunProfile # noqa: I001
from .caddy import Caddy
from .httpd import Httpd
from .curl import CurlClient, ExecResult, RunProfile
from .certs import Credentials, TestCA
from .client import LocalClient
from .nghttpx import Nghttpx, NghttpxQuic, NghttpxFwd
from .vsftpd import VsFTPD
from .dante import Dante
from .env import Env
from .httpd import Httpd
from .nghttpx import Nghttpx, NghttpxFwd, NghttpxQuic
from .sshd import Sshd
from .vsftpd import VsFTPD

View file

@ -29,7 +29,7 @@ import os
import socket
import subprocess
import time
from datetime import timedelta, datetime
from datetime import datetime, timedelta
from json import JSONEncoder
from typing import Dict

View file

@ -30,8 +30,8 @@ import os
import re
import shutil
import subprocess
from datetime import timedelta, datetime, timezone
from typing import List, Any, Optional
from datetime import datetime, timedelta, timezone
from typing import Any, List, Optional
from cryptography import x509
from cryptography.hazmat.backends import default_backend
@ -40,10 +40,14 @@ from cryptography.hazmat.primitives._serialization import PublicFormat
from cryptography.hazmat.primitives.asymmetric import ec, rsa
from cryptography.hazmat.primitives.asymmetric.ec import EllipticCurvePrivateKey
from cryptography.hazmat.primitives.asymmetric.rsa import RSAPrivateKey
from cryptography.hazmat.primitives.serialization import Encoding, PrivateFormat, NoEncryption, load_pem_private_key
from cryptography.hazmat.primitives.serialization import (
Encoding,
NoEncryption,
PrivateFormat,
load_pem_private_key,
)
from cryptography.x509 import ExtendedKeyUsageOID, NameOID
EC_SUPPORTED = {}
EC_SUPPORTED.update([(curve.name.upper(), curve) for curve in [
ec.SECP192R1,

View file

@ -29,12 +29,11 @@ import os
import shutil
import subprocess
from datetime import datetime
from typing import Optional, Dict
from typing import Dict, Optional
from . import ExecResult
from .env import Env
log = logging.getLogger(__name__)

View file

@ -27,22 +27,21 @@
import json
import logging
import os
import sys
import time
from functools import cmp_to_key
from threading import Thread
import psutil
import re
import shutil
import subprocess
from statistics import mean, fmean
from datetime import timedelta, datetime, timezone
from typing import List, Optional, Dict, Union, Any
import sys
import time
from datetime import datetime, timedelta, timezone
from functools import cmp_to_key
from statistics import fmean, mean
from threading import Thread
from typing import Any, Dict, List, Optional, Union
from urllib.parse import urlparse
from .env import Env
import psutil
from .env import Env
log = logging.getLogger(__name__)

View file

@ -29,8 +29,7 @@ import os
import socket
import subprocess
import time
from datetime import timedelta, datetime
from datetime import datetime, timedelta
from typing import Dict
from . import CurlClient

View file

@ -33,14 +33,13 @@ import subprocess
import tempfile
from configparser import ConfigParser, ExtendedInterpolation
from datetime import timedelta
from typing import Optional, Dict, List
from typing import Dict, List, Optional
import pytest
from filelock import FileLock
from .certs import CertificateSpec, Credentials, TestCA
log = logging.getLogger(__name__)

View file

@ -24,17 +24,17 @@
#
###########################################################################
#
import copy
import inspect
import logging
import os
import shutil
import socket
import subprocess
from datetime import timedelta, datetime
from json import JSONEncoder
import time
from typing import List, Union, Optional, Dict
import copy
from datetime import datetime, timedelta
from json import JSONEncoder
from typing import Dict, List, Optional, Union
from .curl import CurlClient, ExecResult
from .env import Env

View file

@ -30,11 +30,11 @@ import signal
import socket
import subprocess
import time
from typing import Optional, Dict
from datetime import datetime, timedelta
from typing import Dict, Optional
from .env import Env, NghttpxUtil
from .curl import CurlClient
from .env import Env, NghttpxUtil
from .ports import alloc_ports_and_do
log = logging.getLogger(__name__)

View file

@ -30,8 +30,7 @@ import socket
import stat
import subprocess
import time
from datetime import timedelta, datetime
from datetime import datetime, timedelta
from typing import Dict
from . import CurlClient

View file

@ -30,9 +30,8 @@ import re
import socket
import subprocess
import time
from datetime import datetime, timedelta
from typing import List, Dict
from typing import Dict, List
from .curl import CurlClient, ExecResult
from .env import Env

View file

@ -23,8 +23,7 @@
#
"""A telnet server which negotiates."""
from __future__ import (absolute_import, division, print_function,
unicode_literals)
from __future__ import absolute_import, division, print_function, unicode_literals
import argparse
import logging

View file

@ -24,13 +24,13 @@
"""Server for testing SMB."""
import argparse
import configparser
import logging
import os
import signal
import sys
import tempfile
import threading
import configparser
# Import our curl test data helper
from util import ClosingFileHandler, TestData
@ -45,8 +45,7 @@ except ImportError:
sys.exit(1)
from impacket import smb as imp_smb
from impacket import smbserver as imp_smbserver
from impacket.nt_errors import (STATUS_ACCESS_DENIED, STATUS_NO_SUCH_FILE,
STATUS_SUCCESS)
from impacket.nt_errors import STATUS_ACCESS_DENIED, STATUS_NO_SUCH_FILE, STATUS_SUCCESS
log = logging.getLogger(__name__)
SERVER_MAGIC = "SERVER_MAGIC"