MCPcopy Create free account
hub / github.com/fabioz/PyDev.Debugger / test_pandas

Function test_pandas

tests_python/test_debugger_json.py:6567–6642  ·  view source on GitHub ↗
(case_setup_dap, pyfile)

Source from the content-addressed store, hash-verified

6565
6566@pytest.mark.skipif(pandas is None, reason="Pandas not installed.")
6567def test_pandas(case_setup_dap, pyfile):
6568
6569 @pyfile
6570 def pandas_mod():
6571 import pandas as pd
6572 import numpy as np
6573
6574 rows = 5000
6575 cols = 50
6576
6577 # i.e.: even with these setting our repr will print at most 300 lines/cols by default.
6578 pd.set_option("display.max_columns", None)
6579 pd.set_option("display.max_rows", None)
6580
6581 items = rows * cols
6582 df = pd.DataFrame(np.arange(items).reshape(rows, cols)).map(lambda x: "Test String")
6583 series = df._series[0]
6584 styler = df.style
6585
6586 print("TEST SUCEEDED") # Break here
6587
6588 with case_setup_dap.test_file(pandas_mod) as writer:
6589 json_facade = JsonFacade(writer)
6590 json_facade.write_launch(justMyCode=False)
6591
6592 bp = writer.get_line_index_with_content("Break here")
6593 json_facade.write_set_breakpoints([bp])
6594
6595 json_facade.write_make_initial_run()
6596
6597 json_hit = json_facade.wait_for_thread_stopped()
6598 # json_hit = json_facade.get_stack_as_json_hit(json_hit.thread_id)
6599 name_to_var = json_facade.get_locals_name_to_var(json_hit.frame_id)
6600
6601 # Check the custom repr(DataFrame)
6602 assert name_to_var["df"].value.count("\n") <= 63
6603 assert "..." in name_to_var["df"].value
6604
6605 evaluate_response = json_facade.evaluate("df", json_hit.frame_id, context="repl")
6606 evaluate_response_body = evaluate_response.body.to_dict()
6607 assert "..." not in evaluate_response_body["result"]
6608 assert evaluate_response_body["result"].count("\n") > 4999
6609
6610 # Check the custom repr(Series)
6611 assert name_to_var["series"].value.count("\n") <= 60
6612 assert "..." in name_to_var["series"].value
6613
6614 # Check custom listing (DataFrame)
6615 df_variables_response = json_facade.get_variables_response(name_to_var["df"].variablesReference)
6616 for v in df_variables_response.body.variables:
6617 if v["name"] == "T":
6618 assert v["value"] == "'<transposed dataframe -- debugger:skipped eval>'"
6619 break
6620 else:
6621 raise AssertionError('Did not find variable "T".')
6622
6623 # Check custom listing (Series)
6624 df_variables_response = json_facade.get_variables_response(name_to_var["series"].variablesReference)

Callers

nothing calls this directly

Calls 13

write_launchMethod · 0.95
write_set_breakpointsMethod · 0.95
evaluateMethod · 0.95
write_continueMethod · 0.95
JsonFacadeClass · 0.85
test_fileMethod · 0.80
countMethod · 0.45

Tested by

no test coverage detected