code: def test_database_args(test_dir):
      custom_port = 26999
      testlogger.debug(test_dir)
      db_port = sherpa.core._port_finder(27000, 28000)
      with warnings.catch_warnings(record=True) as w:
          warnings.simplefilter("always")
          with sherpa.database._Database(
              test_dir, port=db_port, mongodb_args={"port": custom_port}
          ) as db:
              assert len(w) == 1
              assert issubclass(w[-1].category, UserWarning)
              assert "Set port via the db_port" in str(w[-1].message)
  
              # test that there is something running on that port
              db2 = sherpa.database._Database(
                  test_dir, port=custom_port
              )
              with pytest.raises(OSError):
                  db2.start()
  
file_path: sherpa/tests/test_database.py
imports: import os
  import pytest
  import sys
  import sherpa
  import sherpa.core
  import sherpa.schedulers
  import sherpa.database
  import logging
  import time
  import warnings
  from testing_utils import *
label_desc: Use image node_id 2 for calling a global function with example usage: test_database_args(test_dir) without return types