Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/run-pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Run pytests

on:
push:
branches: [dev]
branches: [dev, vr/fix-tests]
pull_request:
branches: [master]

Expand All @@ -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:
Expand Down
17 changes: 16 additions & 1 deletion attmap/attmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
1 change: 1 addition & 0 deletions requirements/requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
coveralls
numpy
pytest>=4.6.9
pytest-cov>=2.8.1
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 7 additions & 1 deletion tests/test_AttMap.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import itertools
import os
import sys
import pickle

import numpy as np
Expand Down Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion tests/test_basic_ops_dynamic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down