Skip to content

Configs Module Testsโš“๏ธŽ

Overviewโš“๏ธŽ

The configs module tests (test_configs.py) verify the configuration management functionality, including path definitions, scheduler detection, and configuration utilities.

Test Casesโš“๏ธŽ

test_paths_existโš“๏ธŽ

Verifies that all important paths defined in the configs module exist.

def test_paths_exist(self):
    """Test that important paths exist."""
    assert configs.HERE.exists()
    assert configs.PROJECT_DIR.exists()
    assert configs.CONF_DIR.exists()
    assert configs.BIN_DIR.exists()

test_scheduler_detectionโš“๏ธŽ

Tests the scheduler detection functionality.

def test_scheduler_detection(self):
    """Test scheduler detection."""
    scheduler = configs.get_scheduler()
    assert scheduler is not None
    assert isinstance(scheduler, str)

test_command_existsโš“๏ธŽ

Verifies the command existence checking function.

def test_command_exists(self):
    """Test command_exists function."""
    # Test with a command that should exist
    assert configs.command_exists("python") is True
    # Test with a command that should not exist
    assert configs.command_exists("nonexistent_command_xyz") is False

test_logging_configโš“๏ธŽ

Tests the logging configuration generation.

def test_logging_config(self):
    """Test get_logging_config function."""
    config = configs.get_logging_config()
    assert isinstance(config, dict)
    assert "version" in config
    assert "handlers" in config
    assert "loggers" in config

test_train_configโš“๏ธŽ

Verifies the TrainConfig dataclass functionality.

def test_train_config(self):
    """Test TrainConfig dataclass."""
    config = configs.TrainConfig(
        model_name_or_path="test-model",
        output_dir="/tmp/test",
        # ... other parameters
    )
    assert config.model_name_or_path == "test-model"
    assert config.output_dir == "/tmp/test"

Running Testsโš“๏ธŽ

python -m pytest tests/test_configs.py