Quench a bunch of warnings

This commit is contained in:
Hynek Schlawack 2018-10-19 10:48:09 +02:00
parent dcfcf5e022
commit 290cf2a3f0
5 changed files with 28 additions and 31 deletions

View File

@ -14,6 +14,7 @@ addopts = -ra
testpaths = tests
filterwarnings =
once::Warning
ignore:::pympler[.*]
[isort]

View File

@ -41,7 +41,7 @@ EXTRAS_REQUIRE = {
"coverage",
"hypothesis",
"pympler",
"pytest",
"pytest<3.9",
"six",
"zope.interface",
],

View File

@ -20,6 +20,7 @@ else:
if PY2:
from UserDict import IterableUserDict
from collections import Mapping, Sequence # noqa
# We 'bundle' isclass instead of using inspect as importing inspect is
# fairly expensive (order of 10-15 ms for a modern machine in 2016)
@ -89,8 +90,27 @@ if PY2:
res.data.update(d) # We blocked update, so we have to do it like this.
return res
def just_warn(*args, **kw): # pragma: nocover
"""
We only warn on Python 3 because we are not aware of any concrete
consequences of not setting the cell on Python 2.
"""
else:
else: # Python 3 and later.
from collections.abc import Mapping, Sequence # noqa
def just_warn(*args, **kw):
"""
We only warn on Python 3 because we are not aware of any concrete
consequences of not setting the cell on Python 2.
"""
warnings.warn(
"Missing ctypes. Some features like bare super() or accessing "
"__class__ will not work with slots classes.",
RuntimeWarning,
stacklevel=2,
)
def isclass(klass):
return isinstance(klass, type)
@ -113,30 +133,6 @@ def import_ctypes():
return ctypes
if not PY2:
def just_warn(*args, **kw):
"""
We only warn on Python 3 because we are not aware of any concrete
consequences of not setting the cell on Python 2.
"""
warnings.warn(
"Missing ctypes. Some features like bare super() or accessing "
"__class__ will not work with slots classes.",
RuntimeWarning,
stacklevel=2,
)
else:
def just_warn(*args, **kw): # pragma: nocover
"""
We only warn on Python 3 because we are not aware of any concrete
consequences of not setting the cell on Python 2.
"""
def make_set_closure_cell():
"""
Moved into a function for testability.

View File

@ -4,7 +4,7 @@ Tests for `attr._funcs`.
from __future__ import absolute_import, division, print_function
from collections import Mapping, OrderedDict, Sequence
from collections import OrderedDict
import pytest
@ -14,7 +14,7 @@ from hypothesis import strategies as st
import attr
from attr import asdict, assoc, astuple, evolve, fields, has
from attr._compat import TYPE
from attr._compat import TYPE, Mapping, Sequence, ordered_dict
from attr.exceptions import AttrsAttributeNotFoundError
from attr.validators import instance_of
@ -163,10 +163,10 @@ class TestAsDict(object):
@given(simple_classes())
def test_asdict_preserve_order(self, cls):
"""
Field order should be preserved when dumping to OrderedDicts.
Field order should be preserved when dumping to an ordered_dict.
"""
instance = cls()
dict_instance = asdict(instance, dict_factory=OrderedDict)
dict_instance = asdict(instance, dict_factory=ordered_dict)
assert [a.name for a in fields(cls)] == list(dict_instance.keys())

View File

@ -45,7 +45,7 @@ deps =
black
commands =
flake8 src tests setup.py conftest.py docs/conf.py
black --check --verbose setup.py conftest.py src tests docs/conf.py
black --check setup.py conftest.py src tests docs/conf.py
[testenv:pre-commit]