Skip to content

Commit

Permalink
Add a wrapt.ObjectProxy test.
Browse files Browse the repository at this point in the history
  • Loading branch information
gpshead committed Oct 8, 2021
1 parent 2da4ccc commit cfe768b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ install_requires =

tests_require =
pytest
wrapt

pandas>=0.24.2,<0.25; python_version=='2.7' and platform_python_implementation != 'PyPy'
numpy>=1.16.3,<1.17; python_version=='2.7' and platform_python_implementation != 'PyPy'
Expand All @@ -48,6 +49,7 @@ tests_require =
[options.extras_require]
tests =
pytest
wrapt

pandas>=0.24.2,<0.25; python_version=='2.7' and platform_python_implementation != 'PyPy'
numpy>=1.16.3,<1.17; python_version=='2.7' and platform_python_implementation != 'PyPy'
Expand Down
11 changes: 9 additions & 2 deletions tests/test_cheap_repr.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,9 @@ def test_array(self):
self.assert_cheap_repr(array('l', range(10)),
"array('l', [0, 1, 2, ..., 8, 9])")

def test_wrapt_objectproxy(self):
def test_uninitialized_class_with_getattr(self):
"""An oversimplified wrapt.ObjectProxy style example."""

# No need to import wrapt, we recreate a tiny similar scenario.
class DemonstrateBug(object):
"""
This class mirrors what effectively happens with wrapt.ObjectProxy
Expand Down Expand Up @@ -261,6 +261,13 @@ def __getattr__(self, name):

DemonstrateBug()

def test_wrapt_objectproxy(self):
import wrapt
class Uhoh(wrapt.ObjectProxy):
def __init__(self):
cheap_repr(self)
Uhoh()

def test_django_queryset(self):
os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.fake_django_settings'
import django
Expand Down

0 comments on commit cfe768b

Please sign in to comment.