Spaces:
Sleeping
Sleeping
File size: 3,554 Bytes
3860419 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# Generated by CodiumAI
import pytest
from gpt_engineer.benchmark.bench_config import (
AppsConfig,
BenchConfig,
GptmeConfig,
MbppConfig,
)
class TestBenchConfig:
# Creating a BenchConfig object with default values should return an instance of BenchConfig with all attributes set to their default values.
def test_default_values(self):
config = BenchConfig()
assert isinstance(config.apps, AppsConfig)
assert isinstance(config.mbpp, MbppConfig)
assert isinstance(config.gptme, GptmeConfig)
assert config.apps.active is True
assert config.apps.test_start_index == 0
assert config.apps.test_end_index == 1
assert config.apps.train_start_index == 0
assert config.apps.train_end_index == 0
assert config.mbpp.active is True
assert config.mbpp.test_len == 1
assert config.mbpp.train_len == 0
assert config.gptme.active is True
# Creating a BenchConfig object with specific values should return an instance of BenchConfig with the specified attributes set to the specified values.
def test_specific_values(self):
config = BenchConfig(
apps=AppsConfig(
active=False,
test_start_index=1,
test_end_index=2,
train_start_index=3,
train_end_index=4,
),
mbpp=MbppConfig(active=False, test_len=5, train_len=6),
gptme=GptmeConfig(active=False),
)
assert isinstance(config.apps, AppsConfig)
assert isinstance(config.mbpp, MbppConfig)
assert isinstance(config.gptme, GptmeConfig)
assert config.apps.active is False
assert config.apps.test_start_index == 1
assert config.apps.test_end_index == 2
assert config.apps.train_start_index == 3
assert config.apps.train_end_index == 4
assert config.mbpp.active is False
assert config.mbpp.test_len == 5
assert config.mbpp.train_len == 6
assert config.gptme.active is False
# Calling the from_dict method with a valid dictionary should return an instance of BenchConfig with attributes set according to the values in the dictionary.
def test_from_dict_valid_dict(self):
config_dict = {
"apps": {
"active": False,
"test_start_index": 1,
"test_end_index": 2,
"train_start_index": 3,
"train_end_index": 4,
},
"mbpp": {"active": False, "test_len": 5, "train_len": 6},
"gptme": {"active": False},
}
config = BenchConfig.from_dict(config_dict)
assert isinstance(config.apps, AppsConfig)
assert isinstance(config.mbpp, MbppConfig)
assert isinstance(config.gptme, GptmeConfig)
assert config.apps.active is False
assert config.apps.test_start_index == 1
assert config.apps.test_end_index == 2
assert config.apps.train_start_index == 3
assert config.apps.train_end_index == 4
assert config.mbpp.active is False
assert config.mbpp.test_len == 5
assert config.mbpp.train_len == 6
assert config.gptme.active is False
# Calling the from_toml method with an invalid path to a TOML file should raise an appropriate exception.
def test_from_toml_invalid_path(self):
config_file = "invalid_config.toml"
with pytest.raises(Exception):
BenchConfig.from_toml(config_file)
|