Ignore ResourceWarnings in various modules in a 2-compatible way.

Sometimes tests are flaky about giving this warning, particularly in ACME. I recommend just ignoring them.
This commit is contained in:
Erica Portnoy
2018-11-01 17:56:01 -07:00
parent c699a50983
commit 36b6328acd
7 changed files with 31 additions and 10 deletions
+3 -2
View File
@@ -16,8 +16,9 @@ from acme import errors
from acme import test_util
from acme.magic_typing import List # pylint: disable=unused-import, no-name-in-module
# turns all warnings into errors for this module
pytestmark = pytest.mark.filterwarnings("ignore::ResourceWarning")
# turns all ResourceWarnings into errors for this module
if six.PY3:
pytestmark = pytest.mark.filterwarnings("ignore::ResourceWarning")
class SSLSocketAndProbeSNITest(unittest.TestCase):
+5 -1
View File
@@ -4,6 +4,7 @@ import unittest
import josepy as jose
import mock
import pytest
import six
from acme import challenges
from acme import test_util
@@ -14,6 +15,10 @@ CERT = test_util.load_comparable_cert('cert.der')
CSR = test_util.load_comparable_csr('csr.der')
KEY = test_util.load_rsa_private_key('rsa512_key.pem')
# turns all ResourceWarnings into errors for this module
if six.PY3:
pytestmark = pytest.mark.filterwarnings("ignore::ResourceWarning")
class ErrorTest(unittest.TestCase):
"""Tests for acme.messages.Error."""
@@ -167,7 +172,6 @@ class DirectoryTest(unittest.TestCase):
from acme.messages import Directory
Directory.from_json({'foo': 'bar'})
@pytest.mark.filterwarnings("ignore::ResourceWarning")
def test_iter_meta(self):
result = False
for k in self.dir.meta:
+4 -2
View File
@@ -6,6 +6,7 @@ import threading
import tempfile
import unittest
import six
from six.moves import http_client # pylint: disable=import-error
from six.moves import queue # pylint: disable=import-error
from six.moves import socketserver # type: ignore # pylint: disable=import-error
@@ -20,8 +21,9 @@ from acme import crypto_util
from acme import test_util
from acme.magic_typing import Set # pylint: disable=unused-import, no-name-in-module
# turns all warnings into errors for this module
pytestmark = pytest.mark.filterwarnings("ignore::ResourceWarning")
# turns all ResourceWarnings into errors for this module
if six.PY3:
pytestmark = pytest.mark.filterwarnings("ignore::ResourceWarning")
class TLSServerTest(unittest.TestCase):
+7
View File
@@ -1,6 +1,13 @@
"""Tests for acme.util."""
import unittest
import pytest
import six
# turns all ResourceWarnings into errors for this module
if six.PY3:
pytestmark = pytest.mark.filterwarnings("ignore::ResourceWarning")
class MapKeysTest(unittest.TestCase):
"""Tests for acme.util.map_keys."""