code: def test_train(tmp_path):
      train_data = create_dataset()
  
      with pytest.raises(ValueError):
          train("non-existing-model-123", None)
  
      # with pytest.raises(ValueError):
      #     train("random-forest", None, config={"non-existing-parameter": 123})
  
      # With save=False (this has to be checked first, so tmp_path is still empty)
      model_wrapper = train(
          "random-forest",
          train_data=train_data,
          dry_run=True,
          save=False,
      )
      assert isinstance(model_wrapper, ModelWrapper)
      assert not any(tmp_path.iterdir())  # is empty dir
  
      # With all datasets
      model_wrapper = train(
          "random-forest",
          train_data=train_data,
          val_data=train_data,
          test_data=train_data,
          dry_run=True,
          save=tmp_path,
      )
      assert isinstance(model_wrapper, ModelWrapper)
      assert (tmp_path / "info.yml").exists()
      assert (tmp_path / "model.joblib").exists()
  
      # With only train data
      model_wrapper = train(
          "random-forest",
          train_data=train_data,
          dry_run=True,
          save=tmp_path,
      )
      assert isinstance(model_wrapper, ModelWrapper)
      assert (tmp_path / "info.yml").exists()
      assert (tmp_path / "model.joblib").exists()
  
file_path: traintool/tests/test_main.py
imports: import comet_ml
  import pytest
  from tensorboardX import SummaryWriter
  from conftest import create_dataset
  from traintool.main import connect_comet, train, load, _resolve_model, _write_info_file, _read_info_file, _create_comet_experiment, _create_tensorboard_writer
  from traintool.model_wrapper import ModelWrapper
  from traintool.utils import DummyExperiment
label_desc: Use image node_id 5 for calling a global function with example usage: test_train(tmp_path) without return types