code: def test_ls(mock_print_format_output, start_ray, tmpdir):
      """This test captures output of list_trials."""
      experiment_name = "test_ls"
      experiment_path = os.path.join(str(tmpdir), experiment_name)
      num_samples = 3
      tune.run(
          "__fake",
          name=experiment_name,
          stop={"training_iteration": 1},
          num_samples=num_samples,
          storage_path=str(tmpdir),
      )
  
      columns = [
          "episode_reward_mean",
          "training_iteration",
          "trial_id",
      ]
      limit = 2
      commands.list_trials(
          experiment_path, info_keys=columns, limit=limit
      )
  
      # The dataframe that is printed as a table is the first arg of the last
      # call made to `ray.tune.cli.commands.print_format_output`.
      mock_print_format_output.assert_called()
      args, _ = mock_print_format_output.call_args_list[-1]
      df = args[0]
      assert sorted(df.columns.to_list()) == sorted(columns), df
      assert len(df.index) == limit, df
  
      commands.list_trials(
          experiment_path,
          sort=["trial_id"],
          info_keys=("trial_id", "training_iteration"),
          filter_op="training_iteration == 1",
      )
      args, _ = mock_print_format_output.call_args_list[-1]
      df = args[0]
      assert sorted(df.columns.to_list()) == sorted(
          ["trial_id", "training_iteration"]
      )
      assert len(df.index) == num_samples
  
      with pytest.raises(click.ClickException):
          commands.list_trials(
              experiment_path,
              sort=["trial_id"],
              info_keys=("training_iteration",),
          )
  
      with pytest.raises(click.ClickException):
          commands.list_trials(experiment_path, info_keys=("asdf",))
  
imports: import click
  import os
  import pytest
  import random
  import subprocess
  import sys
  import time
  from unittest import mock
  import ray
  import ray.train
  from ray import tune
  from ray.rllib import _register_all
  from ray.tune.cli import commands
  from ray.tune.result import CONFIG_PREFIX
  from ray.train.tests.util import create_dict_checkpoint
label_desc: Use image node_id 3 for calling a global function with example usage: test_ls(mock_print_format_output, start_ray, tmpdir) without return types