Author: twm Reviewer: glyph Fixes: ticket:10292
Fix bad test skips
14 | 14 | from itertools import cycle |
|
15 | 15 | from random import randrange |
|
16 | 16 | from signal import SIGINT |
|
17 | + | from typing import Optional |
|
17 | 18 | ||
18 | 19 | from twisted.python.reflect import ObjectNotFound, namedAny |
|
19 | 20 | ||
21 | + | platformSkip: Optional[str] |
|
20 | 22 | try: |
|
21 | 23 | namedAny("fcntl.ioctl") |
|
22 | 24 | except (ObjectNotFound, AttributeError): |
|
23 | 25 | platformSkip = "Platform is missing fcntl/ioctl support" |
|
24 | 26 | else: |
|
25 | - | platformSkip = "" |
|
27 | + | platformSkip = None |
|
26 | 28 | ||
27 | 29 | from zope.interface import Interface, implementer |
|
28 | 30 | from zope.interface.verify import verifyObject |
662 | 664 | instances as the provider of that interface. |
|
663 | 665 | """ |
|
664 | 666 | ||
665 | - | if platformSkip: |
|
666 | - | skip = platformSkip |
|
667 | + | skip = platformSkip |
|
667 | 668 | ||
668 | 669 | def createSystem(self): |
|
669 | 670 | """ |
11 | 11 | import re |
|
12 | 12 | from io import BytesIO |
|
13 | 13 | from typing import Any, List, Optional, Tuple, Type |
|
14 | - | from unittest import skipIf |
|
15 | 14 | ||
16 | 15 | from zope.interface import directlyProvides, implementer |
|
17 | 16 |
32 | 31 | from twisted.test.proto_helpers import MemoryReactor, StringTransport |
|
33 | 32 | from twisted.trial.unittest import TestCase |
|
34 | 33 | ||
34 | + | sslSkip: Optional[str] |
|
35 | 35 | try: |
|
36 | 36 | from twisted.test.ssl_helpers import ClientTLSContext, ServerTLSContext |
|
37 | 37 | except ImportError: |
|
38 | 38 | sslSkip = "OpenSSL not present" |
|
39 | 39 | else: |
|
40 | - | sslSkip = "" |
|
40 | + | sslSkip = None |
|
41 | 41 | ||
42 | 42 | ||
43 | 43 | if not interfaces.IReactorSSL.providedBy(reactor): |
653 | 653 | self.tls = True |
|
654 | 654 | ||
655 | 655 | ||
656 | - | @skipIf(sslSkip, sslSkip) |
|
657 | 656 | class TLSTests(TestCase, LoopbackMixin): |
|
657 | + | skip = sslSkip |
|
658 | + | ||
658 | 659 | def testTLS(self): |
|
659 | 660 | clientCTX = ClientTLSContext() |
|
660 | 661 | serverCTX = ServerTLSContext() |
1595 | 1596 | self.assertEqual(b"HELO testuser\r\n", transport.value()) |
|
1596 | 1597 | ||
1597 | 1598 | ||
1598 | - | @skipIf(sslSkip, sslSkip) |
|
1599 | 1599 | class SSLTestCase(TestCase): |
|
1600 | 1600 | """ |
|
1601 | 1601 | Tests for the TLS negotiation done by L{smtp.ESMTPClient}. |
|
1602 | 1602 | """ |
|
1603 | 1603 | ||
1604 | + | skip = sslSkip |
|
1605 | + | ||
1604 | 1606 | SERVER_GREETING = b"220 localhost NO UCE NO UBE NO RELAY PROBES ESMTP\r\n" |
|
1605 | 1607 | EHLO_RESPONSE = b"250-localhost Hello 127.0.0.1, nice to meet you\r\n" |
|
1606 | 1608 |
29 | 29 | pyasn1 = requireModule("pyasn1") |
|
30 | 30 | cryptography = requireModule("cryptography") |
|
31 | 31 | ||
32 | + | dependencySkip: Optional[str] |
|
32 | 33 | if pyasn1 and cryptography: |
|
33 | - | dependencySkip = "" |
|
34 | + | dependencySkip = None |
|
34 | 35 | from cryptography.exceptions import UnsupportedAlgorithm |
|
35 | 36 | from cryptography.hazmat.backends import default_backend |
|
36 | 37 | from cryptography.hazmat.primitives import serialization |
9 | 9 | import errno |
|
10 | 10 | import os |
|
11 | 11 | import sys |
|
12 | - | from unittest import skipIf |
|
12 | + | from typing import Optional |
|
13 | 13 | ||
14 | + | platformSkip: Optional[str] |
|
14 | 15 | try: |
|
15 | 16 | import fcntl |
|
16 | 17 | except ImportError: |
18 | 19 | else: |
|
19 | 20 | from twisted.internet import process |
|
20 | 21 | ||
21 | - | platformSkip = "" |
|
22 | + | platformSkip = None |
|
22 | 23 | ||
23 | 24 | from twisted.trial.unittest import TestCase |
|
24 | 25 |
64 | 65 | return [123, 456] |
|
65 | 66 | ||
66 | 67 | ||
67 | - | @skipIf(platformSkip, platformSkip) |
|
68 | 68 | class FDDetectorTests(TestCase): |
|
69 | 69 | """ |
|
70 | 70 | Tests for _FDDetector class in twisted.internet.process, which detects |
80 | 80 | that /proc/<pid>/fd exists. |
|
81 | 81 | """ |
|
82 | 82 | ||
83 | + | skip = platformSkip |
|
84 | + | ||
83 | 85 | devfs = False |
|
84 | 86 | accurateDevFDResults = False |
|
85 | 87 |
278 | 280 | ) |
|
279 | 281 | ||
280 | 282 | ||
281 | - | @skipIf(platformSkip, platformSkip) |
|
282 | 283 | class FileDescriptorTests(TestCase): |
|
283 | 284 | """ |
|
284 | 285 | Tests for L{twisted.internet.process._listOpenFDs} |
|
285 | 286 | """ |
|
286 | 287 | ||
288 | + | skip = platformSkip |
|
289 | + | ||
287 | 290 | def test_openFDs(self): |
|
288 | 291 | """ |
|
289 | 292 | File descriptors returned by L{_listOpenFDs} are mostly open. |
26 | 26 | from twisted.test import proto_helpers |
|
27 | 27 | from twisted.trial import unittest |
|
28 | 28 | ||
29 | - | if platform.isWindows(): |
|
30 | - | windowsSkip = "These tests need more work before they'll work on Windows." |
|
29 | + | if not platform.isWindows(): |
|
30 | + | windowsSkip = None |
|
31 | 31 | else: |
|
32 | - | windowsSkip = "" |
|
32 | + | windowsSkip = "These tests need more work before they'll work on Windows." |
|
33 | 33 | ||
34 | 34 | ||
35 | 35 | class FakeResolver(ResolverBase): |
99 | 99 | Tests for L{client.getResolver}. |
|
100 | 100 | """ |
|
101 | 101 | ||
102 | - | if windowsSkip: |
|
103 | - | skip = windowsSkip |
|
102 | + | skip = windowsSkip |
|
104 | 103 | ||
105 | 104 | def test_interface(self): |
|
106 | 105 | """ |
126 | 125 | Tests for L{client.createResolver}. |
|
127 | 126 | """ |
|
128 | 127 | ||
129 | - | if windowsSkip: |
|
130 | - | skip = windowsSkip |
|
128 | + | skip = windowsSkip |
|
131 | 129 | ||
132 | 130 | def _hostsTest(self, resolver, filename): |
|
133 | 131 | res = [r for r in resolver.resolvers if isinstance(r, hosts.Resolver)] |
11 | 11 | import random |
|
12 | 12 | import string |
|
13 | 13 | from io import BytesIO |
|
14 | - | from unittest import skipIf |
|
15 | 14 | ||
16 | 15 | from zope.interface import implementer |
|
17 | 16 | from zope.interface.verify import verifyClass |
26 | 25 | from twisted.test import proto_helpers |
|
27 | 26 | from twisted.trial.unittest import TestCase |
|
28 | 27 | ||
29 | - | if runtime.platform.isWindows(): |
|
30 | - | nonPOSIXSkip = "Cannot run on Windows" |
|
28 | + | if not runtime.platform.isWindows(): |
|
29 | + | nonPOSIXSkip = None |
|
31 | 30 | else: |
|
32 | - | nonPOSIXSkip = "" |
|
31 | + | nonPOSIXSkip = "Cannot run on Windows" |
|
33 | 32 | ||
34 | 33 | ||
35 | 34 | class Dummy(basic.LineReceiver): |
2975 | 2974 | self.assertEqual(filepath.FilePath("/home/alice@example.com"), home) |
|
2976 | 2975 | ||
2977 | 2976 | ||
2978 | - | @skipIf(nonPOSIXSkip, nonPOSIXSkip) |
|
2979 | 2977 | class SystemFTPRealmTests(TestCase): |
|
2980 | 2978 | """ |
|
2981 | 2979 | Tests for L{ftp.SystemFTPRealm}. |
|
2982 | 2980 | """ |
|
2983 | 2981 | ||
2982 | + | skip = nonPOSIXSkip |
|
2983 | + | ||
2984 | 2984 | def test_getHomeDirectory(self): |
|
2985 | 2985 | """ |
|
2986 | 2986 | L{ftp.SystemFTPRealm.getHomeDirectory} treats the avatarId passed to it |
Files | Coverage |
---|---|
src/twisted | 89.56% |
Project Totals (830 files) | 89.56% |
1 |
#
|
2 |
# For documentation: https://docs.codecov.io/docs/codecovyml-reference
|
3 |
# Twisted settings: https://codecov.io/gh/twisted/twisted/settings/yaml
|
4 |
#
|
5 |
# We want 100% coverage for new patches to make sure we are always increasing
|
6 |
# the coverage.
|
7 |
#
|
8 |
codecov: |
9 |
require_ci_to_pass: yes |
10 |
notify: |
11 |
# We have at least 10 builds in GitHub Actions and 12 in Azure
|
12 |
# and lint + mypy + docs + ReadTheDocs
|
13 |
after_n_builds: 15 |
14 |
wait_for_ci: yes |
15 |
|
16 |
coverage: |
17 |
precision: 2 |
18 |
round: down |
19 |
status: |
20 |
patch: |
21 |
default: |
22 |
# New code should have 100% CI coverage as the minimum
|
23 |
# quality assurance measurement.
|
24 |
# If there is a good reason for new code not to have coverage,
|
25 |
# add inline pragma comments.
|
26 |
target: 100% |
27 |
project: |
28 |
default: |
29 |
# Temporary allow for a bit of slack in overall code coverage due to
|
30 |
# swinging coverage that is not triggered by changes in a PR.
|
31 |
# See: https://twistedmatrix.com/trac/ticket/10170
|
32 |
threshold: 0.02% |
33 |
|
34 |
|
35 |
# We don't want to receive general PR comments about coverage.
|
36 |
# We have the commit status checks and that should be enough.
|
37 |
# See https://docs.codecov.io/docs/pull-request-comments
|
38 |
comment: false |
39 |
|
40 |
# See https://docs.codecov.io/docs/github-checks
|
41 |
github_checks: |
42 |
# We want codecov to send inline PR comments for missing coverage.
|
43 |
annotations: true |