diff --git a/.github/workflows/run-pytest.yml b/.github/workflows/run-pytest.yml index 1fc5e3b..764aaef 100644 --- a/.github/workflows/run-pytest.yml +++ b/.github/workflows/run-pytest.yml @@ -2,7 +2,7 @@ name: Run pytests on: push: - branches: [dev] + branches: [dev, vr/fix-tests] pull_request: branches: [master] @@ -11,7 +11,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - python-version: [3.6, 3.9] + python-version: ["3.8", "3.11"] os: [ubuntu-latest] steps: diff --git a/attmap/attmap.py b/attmap/attmap.py index 2346954..0340ca0 100644 --- a/attmap/attmap.py +++ b/attmap/attmap.py @@ -109,7 +109,22 @@ def _metamorph_maplike(self, m): raise TypeError( "Cannot integrate a non-Mapping: {}\nType: {}".format(m, type(m)) ) - return self._lower_type_bound(m.items()) + to_return = self._lower_type_bound(m.items()) + + # Don't forget any attributes included in this item, for non-builtin items + if ( + m.__class__.__module__ != "builtins" + and m.__class__.__module__ != "collections" + ): + print(f"Class:{m.__class__.__module__}") + for attr in dir(m): + if attr in m.items(): + continue + if attr[:1] == "_": + continue + to_return.__setattr__(attr, m.__getattribute__(attr)) + + return to_return def _new_empty_basic_map(self): """Return the empty collection builder for Mapping type simplification.""" diff --git a/requirements/requirements-test.txt b/requirements/requirements-test.txt index a1303c8..1e91f21 100644 --- a/requirements/requirements-test.txt +++ b/requirements/requirements-test.txt @@ -1,3 +1,4 @@ coveralls +numpy pytest>=4.6.9 pytest-cov>=2.8.1 diff --git a/setup.py b/setup.py index 094d620..abe1bc2 100644 --- a/setup.py +++ b/setup.py @@ -49,7 +49,7 @@ def read_reqs(reqs_name): ], keywords="dict, map, mapping, dot, item, getitem, attr, getattr, key-value, dynamic, mutable, access", url="https://github.com/pepkit/{}/".format(PACKAGE), - author=u"Nathan Sheffield, Vince Reuter, Michal Stolarczyk", + author="Nathan Sheffield, Vince Reuter, Michal Stolarczyk", license="BSD2", include_package_data=True, test_suite="tests", diff --git a/tests/test_AttMap.py b/tests/test_AttMap.py index b73c08a..205a45f 100644 --- a/tests/test_AttMap.py +++ b/tests/test_AttMap.py @@ -2,6 +2,7 @@ import itertools import os +import sys import pickle import numpy as np @@ -379,7 +380,12 @@ def test_attribute_access(self, return_identity, attr_to_request, attrdict): elif attr_to_request in self.NORMAL_ITEM_ARG_VALUES: # Request for common protected function returns the function. assert callable(getattr(attrdict, attr_to_request)) - elif attr_to_request in self.PICKLE_ITEM_ARG_VALUES: + elif ( + attr_to_request == "__getstate__" + and sys.version_info < (3, 11) + or attr_to_request == "__setstate__" + ): + # See: https://stackoverflow.com/questions/74331573/pyomo-compatibility-with-python-3-11 # We don't tinker with the pickle-relevant attributes. with pytest.raises(AttributeError): print( diff --git a/tests/test_basic_ops_dynamic.py b/tests/test_basic_ops_dynamic.py index ab137eb..02a7889 100644 --- a/tests/test_basic_ops_dynamic.py +++ b/tests/test_basic_ops_dynamic.py @@ -29,7 +29,7 @@ def test_length_decrease(attmap_type, entries): def test_length_increase(attmap_type, entries): """Length/size of an attmap should match number of entries.""" m = get_att_map(attmap_type) - for (i, (k, v)) in enumerate(entries.items()): + for i, (k, v) in enumerate(entries.items()): assert i == len(m) m[k] = v assert (i + 1) == len(m)