(capsys)
| 124 | not haveIPython, reason="Can't run variable tests without IPython console" |
| 125 | ) |
| 126 | def test_dataframe_rows(capsys): |
| 127 | from IPython import get_ipython |
| 128 | |
| 129 | # Setup some different types |
| 130 | path = os.path.dirname(os.path.abspath(__file__)) |
| 131 | file = os.path.abspath(os.path.join(path, "random.csv")) |
| 132 | file = file.replace("\\", "\\\\") |
| 133 | dfstr = "import pandas as pd\r\ndf = pd.read_csv('{}')".format(file) |
| 134 | get_ipython().run_cell(dfstr) |
| 135 | vars = get_variables(capsys) |
| 136 | df = get_variable_value(vars, "df", capsys) |
| 137 | assert df |
| 138 | info = get_data_frame_info(vars, "df", capsys) |
| 139 | assert "rowCount" in info |
| 140 | assert info["rowCount"] == 6000 |
| 141 | rows = get_data_frame_rows(info, 100, 200, capsys) |
| 142 | assert rows |
| 143 | assert rows["data"][0]["+h2"] == "Fy3 W[pMT[" |
| 144 | get_ipython().run_cell( |
| 145 | """ |
| 146 | import pandas as pd |
| 147 | import numpy as np |
| 148 | ls = list([10, 20, 30, 40]) |
| 149 | df = pd.DataFrame(ls) |
| 150 | se = pd.Series(ls) |
| 151 | np1 = np.array(ls) |
| 152 | np2 = np.array([[1, 2, 3], [4, 5, 6]]) |
| 153 | obj = {} |
| 154 | """ |
| 155 | ) |
| 156 | vars = get_variables(capsys) |
| 157 | np2 = get_variable_value(vars, "np2", capsys) |
| 158 | assert np2 |
| 159 | info = get_data_frame_info(vars, "np2", capsys) |
| 160 | assert "rowCount" in info |
| 161 | assert info["rowCount"] == 2 |
| 162 | rows = get_data_frame_rows(info, 0, 2, capsys) |
| 163 | assert rows |
| 164 | assert rows["data"][0] |
nothing calls this directly
no test coverage detected