Open jbrockmendel opened 6 months ago
Can you paste the traceback?
_________________________________________________________ TestTableSchemaRepr.test_publishes __________________________________________________________
self = <pandas.tests.io.formats.test_ipython_compat.TestTableSchemaRepr object at 0x12bb71890>
ip = <IPython.core.interactiveshell.InteractiveShell object at 0x2cc064e10>
def test_publishes(self, ip):
ipython = ip.instance(config=ip.config)
df = DataFrame({"A": [1, 2]})
objects = [df["A"], df] # dataframe / series
expected_keys = [
{"text/plain", "application/vnd.dataresource+json"},
{"text/plain", "text/html", "application/vnd.dataresource+json"},
]
opt = cf.option_context("display.html.table_schema", True)
last_obj = None
for obj, expected in zip(objects, expected_keys):
last_obj = obj
> with opt:
pandas/tests/io/formats/test_ipython_compat.py:25:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <contextlib._GeneratorContextManager object at 0x2d15ac210>
def __enter__(self):
# do not keep args and kwds alive unnecessarily
# they are only needed for recreation, which is not possible anymore
> del self.args, self.kwds, self.func
E AttributeError: '_GeneratorContextManager' object has no attribute 'args'
../../../.pyenv/versions/3.11.7/lib/python3.11/contextlib.py:135: AttributeError
This diff fixes it for me, not sure why though.
Maybe it's an ipython bug?
(opt is cf.option_context("display.html.table_schema", True)
)
diff --git a/pandas/tests/io/formats/test_ipython_compat.py b/pandas/tests/io/formats/test_ipython_compat.py
index 8512f41396..67bb0fb9e3 100644
--- a/pandas/tests/io/formats/test_ipython_compat.py
+++ b/pandas/tests/io/formats/test_ipython_compat.py
@@ -22,7 +22,7 @@ class TestTableSchemaRepr:
last_obj = None
for obj, expected in zip(objects, expected_keys):
last_obj = obj
- with opt:
+ with cf.option_context("display.html.table_schema", True):
formatted = ipython.display_formatter.format(obj)
assert set(formatted[0].keys()) == expected
That fixes it for me too
Happens to me on Windows as well, and that fixes it for me My guess is that this context manager is not re-usable
I've been seeing this for a couple weeks.