Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Aug 10, 2023
1 parent 140e176 commit 97685c3
Show file tree
Hide file tree
Showing 27 changed files with 39 additions and 29 deletions.
2 changes: 1 addition & 1 deletion src/twisted/conch/test/test_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
"""

import struct
from unittest import skipIf

from twisted.python.compat import fips
from twisted.test import iosim
from twisted.trial import unittest
from unittest import skipIf

try:
import cryptography as _cryptography
Expand Down
5 changes: 4 additions & 1 deletion src/twisted/conch/test/test_cftp.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

from zope.interface import implementer

from twisted.python.compat import fips
from twisted.conch import ls
from twisted.conch.interfaces import ISFTPFile
from twisted.conch.test.test_filetransfer import FileTransferTestAvatar, SFTPTestBase
Expand All @@ -28,6 +27,7 @@
from twisted.internet.testing import StringTransport
from twisted.internet.utils import getProcessOutputAndValue, getProcessValue
from twisted.python import log
from twisted.python.compat import fips
from twisted.python.fakepwd import UserDatabase
from twisted.python.filepath import FilePath
from twisted.python.procutils import which
Expand Down Expand Up @@ -940,6 +940,7 @@ class OurServerCmdLineClientTests(CFTPClientTestBase):
Due to the spawned process you can not add a debugger breakpoint for the
client code.
"""

if fips:
skip = "skip when fips enabled"

Expand Down Expand Up @@ -1343,6 +1344,7 @@ class OurServerBatchFileTests(CFTPClientTestBase):
Functional tests which launch a SFTP server over localhost and checks csftp
in batch interface.
"""

if fips:
skip = "skip when fips enabled"

Expand Down Expand Up @@ -1452,6 +1454,7 @@ class OurServerSftpClientTests(CFTPClientTestBase):
"""
Test the sftp server against sftp command line client.
"""

if fips:
skip = "skip when fips enabled"

Expand Down
2 changes: 1 addition & 1 deletion src/twisted/conch/test/test_checkers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
from collections import namedtuple
from io import BytesIO
from typing import Optional
from twisted.python.compat import fips
from unittest import skipIf

from twisted.python.compat import fips

cryptSkip: Optional[str]
try:
Expand Down
3 changes: 2 additions & 1 deletion src/twisted/conch/test/test_ckeygen.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
privateRSA_openssh_encrypted,
publicRSA_openssh,
)
from twisted.python.compat import fips
from twisted.python.filepath import FilePath
from twisted.python.reflect import requireModule
from twisted.trial.unittest import TestCase
from twisted.python.compat import fips

if requireModule("cryptography"):
from twisted.conch.scripts.ckeygen import (
Expand Down Expand Up @@ -64,6 +64,7 @@ class KeyGenTests(TestCase):
"""
Tests for various functions used to implement the I{ckeygen} script.
"""

if fips:
skip = "skip when fips enabled"

Expand Down
5 changes: 3 additions & 2 deletions src/twisted/conch/test/test_conch.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,11 @@
from twisted.internet.task import LoopingCall
from twisted.internet.utils import getProcessValue
from twisted.python import filepath, log, runtime
from twisted.python.compat import fips
from twisted.python.filepath import FilePath
from twisted.python.procutils import which
from twisted.python.reflect import requireModule
from twisted.trial.unittest import SkipTest, TestCase
from twisted.python.compat import fips
from unittest import skipIf

try:
from twisted.conch.test.test_ssh import (
Expand Down Expand Up @@ -716,6 +715,7 @@ class OpenSSHClientForwardingTests(ForwardingMixin, OpenSSHClientMixin, TestCase
"""
Connection forwarding tests run against the OpenSSL command line client.
"""

if fips:
skip = "skip when fips enabled"

Expand All @@ -737,6 +737,7 @@ class OpenSSHClientRekeyTests(RekeyTestsMixin, OpenSSHClientMixin, TestCase):
"""
Rekeying tests run against the OpenSSL command line client.
"""

if fips:
skip = "skip when fips enabled"

Expand Down
1 change: 1 addition & 0 deletions src/twisted/conch/test/test_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,7 @@ class NewConnectionTests(TestCase, SSHCommandClientEndpointTestsMixin):
Tests for L{SSHCommandClientEndpoint} when using the C{newConnection}
constructor.
"""

if fips:
skip = "skip when fips enabled"

Expand Down
2 changes: 1 addition & 1 deletion src/twisted/conch/test/test_forwarding.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
if cryptography:
from twisted.conch.ssh import forwarding

from twisted.python.compat import fips
from twisted.internet.address import IPv6Address
from twisted.python.compat import fips

try:
from twisted.internet.test.test_endpoints import deterministicResolvingReactor
Expand Down
2 changes: 1 addition & 1 deletion src/twisted/conch/test/test_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
import base64
import os
from textwrap import dedent
from unittest import skipIf

from twisted.conch.test import keydata
from twisted.python import randbytes
from twisted.python.compat import fips
from twisted.python.filepath import FilePath
from twisted.python.reflect import requireModule
from twisted.trial import unittest
from unittest import skipIf

cryptography = requireModule("cryptography")
if cryptography is None:
Expand Down
6 changes: 3 additions & 3 deletions src/twisted/conch/test/test_recvline.py
Original file line number Diff line number Diff line change
Expand Up @@ -777,9 +777,9 @@ class HistoricRecvlineLoopbackTelnetTests(
class HistoricRecvlineLoopbackSSHTests(
_SSHMixin, TestCase, HistoricRecvlineLoopbackMixin
):
if fips:
skip = "skip when fips enabled"
pass
if fips:
skip = "skip when fips enabled"
pass


@skipIf(
Expand Down
2 changes: 1 addition & 1 deletion src/twisted/conch/test/test_ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
from twisted.internet import defer, protocol, reactor
from twisted.internet.error import ProcessTerminated
from twisted.python import failure, log
from twisted.python.compat import fips
from twisted.python.reflect import requireModule
from twisted.trial import unittest
from twisted.python.compat import fips

if fips:
skip = "skip when fips enabled"
Expand Down
5 changes: 4 additions & 1 deletion src/twisted/conch/test/test_transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import types
from hashlib import sha1, sha256, sha384, sha512
from typing import Dict, List, Optional, Tuple, Type
from unittest import skipIf

from twisted import __version__ as twisted_version
from twisted.conch.error import ConchError
Expand All @@ -25,7 +26,6 @@
from twisted.python.reflect import requireModule
from twisted.test import proto_helpers
from twisted.trial.unittest import TestCase
from unittest import skipIf

cryptography = requireModule("cryptography")

Expand Down Expand Up @@ -2089,6 +2089,7 @@ class ServerSSHTransportDHGroupExchangeSHA1Tests(
"""
diffie-hellman-group-exchange-sha1 tests for SSHServerTransport.
"""

if fips:
skip = "skip when fips enabled"

Expand All @@ -2101,6 +2102,7 @@ class ServerSSHTransportDHGroupExchangeSHA256Tests(
"""
diffie-hellman-group-exchange-sha256 tests for SSHServerTransport.
"""

if fips:
skip = "skip when fips enabled"

Expand Down Expand Up @@ -3034,6 +3036,7 @@ class TransportLoopbackTests(TestCase):
"""
Test the server transport and client transport against each other,
"""

if fips:
skip = "skip when fips enabled"

Expand Down
1 change: 0 additions & 1 deletion src/twisted/internet/test/test_asyncioreactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
)
from unittest import skipIf

from twisted.python.compat import fips
from twisted.internet.asyncioreactor import AsyncioSelectorReactor
from twisted.python.compat import fips
from twisted.python.runtime import platform
Expand Down
1 change: 0 additions & 1 deletion src/twisted/internet/test/test_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
from twisted.test.iosim import connectableEndpoint, connectedServerAndClient
from twisted.trial import unittest


pemPath = getModule("twisted.test").filePath.sibling("server.pem")
noTrailingNewlineKeyPemPath = getModule("twisted.test").filePath.sibling(
"key.pem.no_trailing_newline"
Expand Down
2 changes: 1 addition & 1 deletion src/twisted/mail/test/test_pop3.py
Original file line number Diff line number Diff line change
Expand Up @@ -1028,10 +1028,10 @@ class SASLTests(unittest.TestCase):
"""
Tests for L{pop3.POP3}'s SASL implementation.
"""

if fips:
skip = "skip when fips enabled"


def test_ValidLogin(self):
"""
A CRAM-MD5-based SASL login attempt succeeds if it uses a username and
Expand Down
2 changes: 1 addition & 1 deletion src/twisted/mail/test/test_pop3client.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
from twisted.mail.test import pop3testserver
from twisted.protocols import basic, loopback
from twisted.python import log
from twisted.trial.unittest import TestCase
from twisted.python.compat import fips
from twisted.trial.unittest import TestCase

try:
from twisted.test.ssl_helpers import ClientTLSContext, ServerTLSContext
Expand Down
1 change: 1 addition & 0 deletions src/twisted/protocols/test/test_tls.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ class TLSMemoryBIOTests(TestCase):
Tests for the implementation of L{ISSLTransport} which runs over another
L{ITransport}.
"""

if fips:
skip = "skip when fips enabled"

Expand Down
1 change: 1 addition & 0 deletions src/twisted/python/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@

try:
from _hashlib import get_fips_mode

fips = get_fips_mode()
except ImportError:
fips = False
Expand Down
2 changes: 1 addition & 1 deletion src/twisted/python/test/test_zipstream.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
import random
import struct
import zipfile
from unittest import skipIf

from twisted.python import filepath, zipstream
from twisted.python.compat import fips, md5
from twisted.trial import unittest
from unittest import skipIf


class FileEntryMixin:
Expand Down
3 changes: 1 addition & 2 deletions src/twisted/spread/test/test_pb.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from collections import deque
from io import BytesIO as StringIO
from typing import Dict
from unittest import skipIf

from zope.interface import Interface, implementer

Expand All @@ -34,7 +35,6 @@
from twisted.python.compat import fips, iterbytes
from twisted.spread import jelly, pb, publish, util
from twisted.trial import unittest
from unittest import skipIf


class Dummy(pb.Viewable):
Expand Down Expand Up @@ -1356,7 +1356,6 @@ class NewCredTests(unittest.TestCase):
if fips:
skip = "skip when fips enabled"


def setUp(self):
"""
Create a portal with no checkers and wrap it around a simple test
Expand Down
2 changes: 1 addition & 1 deletion src/twisted/test/test_amp.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
from twisted.internet.testing import StringTransport
from twisted.protocols import amp
from twisted.python import filepath
from twisted.python.compat import fips
from twisted.python.failure import Failure
from twisted.test import iosim
from twisted.trial.unittest import TestCase
from twisted.python.compat import fips

try:
from twisted.internet import ssl as _ssl
Expand Down
1 change: 1 addition & 0 deletions src/twisted/test/test_sslverify.py
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,7 @@ class OpenSSLOptionsTests(OpenSSLOptionsTestsMixin, TestCase):
"""
Tests for L{sslverify.OpenSSLOptions}.
"""

if fips:
skip = "skip when fips enabled"

Expand Down
2 changes: 1 addition & 1 deletion src/twisted/test/test_tcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@

import hamcrest

from twisted.python.compat import fips
from twisted.internet import defer, error, interfaces, protocol, reactor
from twisted.internet.address import IPv4Address
from twisted.internet.interfaces import IHalfCloseableProtocol, IPullProducer
from twisted.internet.protocol import Protocol
from twisted.internet.testing import AccumulatingProtocol
from twisted.protocols import policies
from twisted.python.compat import fips
from twisted.python.log import err, msg
from twisted.python.runtime import platform
from twisted.trial.unittest import SkipTest, TestCase
Expand Down
2 changes: 1 addition & 1 deletion src/twisted/trial/test/test_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import unittest as pyunit
from operator import attrgetter
from types import ModuleType
from unittest import skipIf

from hamcrest import assert_that, equal_to, has_properties
from hamcrest.core.matcher import Matcher
Expand All @@ -23,7 +24,6 @@
from twisted.trial._asyncrunner import _iterateTests
from twisted.trial.itrial import ITestCase
from twisted.trial.test import packages
from unittest import skipIf
from .matchers import after


Expand Down
4 changes: 2 additions & 2 deletions src/twisted/web/test/test_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
from typing import TYPE_CHECKING, List, Optional, Tuple
from unittest import SkipTest, skipIf

from twisted.python.compat import fips

from zope.interface.declarations import implementer
from zope.interface.verify import verifyObject

Expand All @@ -30,6 +28,8 @@
from twisted.internet.interfaces import IOpenSSLClientConnectionCreator
from twisted.internet.protocol import Factory, Protocol
from twisted.internet.task import Clock
from twisted.python.compat import fips

try:
from twisted.internet.test.test_endpoints import deterministicResolvingReactor
except Exception as e:

Check warning on line 35 in src/twisted/web/test/test_agent.py

View check run for this annotation

Codecov / codecov/patch

src/twisted/web/test/test_agent.py#L35

Added line #L35 was not covered by tests
Expand Down

0 comments on commit 97685c3

Please sign in to comment.