diff --git a/python/.env.versions b/python/.env.versions index 9ccd756e..259de5ad 100644 --- a/python/.env.versions +++ b/python/.env.versions @@ -5,4 +5,5 @@ HATCH_VERSION="1.14.2" # Full pip install command -HATCH_INSTALL_CMD="pip install hatch==${HATCH_VERSION}" \ No newline at end of file +# Pin virtualenv<21 to work around https://github.com/pypa/hatch/issues/2193 +HATCH_INSTALL_CMD="pip install hatch==${HATCH_VERSION} virtualenv<21" \ No newline at end of file diff --git a/python/tests/tsdf_tests.py b/python/tests/tsdf_tests.py index a097a72a..c2ba9c6d 100644 --- a/python/tests/tsdf_tests.py +++ b/python/tests/tsdf_tests.py @@ -372,6 +372,28 @@ def test_show_k_gt_n(self): sys.stdout = captured_output self.assertRaises(ValueError, init_tsdf.show, 5, 10) + def test_show_k_2(self): + """Verify that k limits the number of rows shown per series.""" + init_tsdf = self.get_test_df_builder("init").as_tsdf() + + captured_output = StringIO() + sys.stdout = captured_output + init_tsdf.show(n=20, k=2) + self.assertEqual( + captured_output.getvalue(), + ( + "+------+-------------------+--------+\n" + "|symbol| event_ts|trade_pr|\n" + "+------+-------------------+--------+\n" + "| S1|2020-09-01 00:02:10| 361.1|\n" + "| S1|2020-09-01 00:19:12| 362.1|\n" + "| S2|2020-09-01 00:02:10| 761.1|\n" + "| S2|2020-09-01 00:20:42| 762.33|\n" + "+------+-------------------+--------+\n" + "\n" + ), + ) + def test_show_truncate_false(self): init_tsdf = self.get_test_df_builder("init").as_tsdf() diff --git a/python/tests/unit_test_data/tsdf_tests.json b/python/tests/unit_test_data/tsdf_tests.json index 99386d93..caae53d6 100644 --- a/python/tests/unit_test_data/tsdf_tests.json +++ b/python/tests/unit_test_data/tsdf_tests.json @@ -384,6 +384,11 @@ "$ref": "#/__SharedData/temp_slice_init_data" } }, + "test_show_k_2": { + "init": { + "$ref": "#/__SharedData/temp_slice_init_data" + } + }, "test_show_truncate_false": { "init": { "$ref": "#/__SharedData/temp_slice_init_data"