Spaces:
Runtime error
Runtime error
File size: 2,490 Bytes
e7cae83 |
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 89 90 91 92 93 94 95 96 97 |
from configparser import ConfigParser
import pytest
from facefusion import config
@pytest.fixture(scope = 'module', autouse = True)
def before_all() -> None:
config.CONFIG = ConfigParser()
config.CONFIG.read_dict(
{
'str':
{
'valid': 'a',
'unset': ''
},
'int':
{
'valid': '1',
'unset': ''
},
'float':
{
'valid': '1.0',
'unset': ''
},
'bool':
{
'valid': 'True',
'unset': ''
},
'str_list':
{
'valid': 'a b c',
'unset': ''
},
'int_list':
{
'valid': '1 2 3',
'unset': ''
},
'float_list':
{
'valid': '1.0 2.0 3.0',
'unset': ''
}
})
def test_get_str_value() -> None:
assert config.get_str_value('str.valid') == 'a'
assert config.get_str_value('str.unset', 'b') == 'b'
assert config.get_str_value('str.unset') is None
assert config.get_str_value('str.invalid') is None
def test_get_int_value() -> None:
assert config.get_int_value('int.valid') == 1
assert config.get_int_value('int.unset', '1') == 1
assert config.get_int_value('int.unset') is None
assert config.get_int_value('int.invalid') is None
def test_get_float_value() -> None:
assert config.get_float_value('float.valid') == 1.0
assert config.get_float_value('float.unset', '1.0') == 1.0
assert config.get_float_value('float.unset') is None
assert config.get_float_value('float.invalid') is None
def test_get_bool_value() -> None:
assert config.get_bool_value('bool.valid') is True
assert config.get_bool_value('bool.unset', 'False') is False
assert config.get_bool_value('bool.unset') is None
assert config.get_bool_value('bool.invalid') is None
def test_get_str_list() -> None:
assert config.get_str_list('str_list.valid') == [ 'a', 'b', 'c' ]
assert config.get_str_list('str_list.unset', 'c b a') == [ 'c', 'b', 'a' ]
assert config.get_str_list('str_list.unset') is None
assert config.get_str_list('str_list.invalid') is None
def test_get_int_list() -> None:
assert config.get_int_list('int_list.valid') == [ 1, 2, 3 ]
assert config.get_int_list('int_list.unset', '3 2 1') == [ 3, 2, 1 ]
assert config.get_int_list('int_list.unset') is None
assert config.get_int_list('int_list.invalid') is None
def test_get_float_list() -> None:
assert config.get_float_list('float_list.valid') == [ 1.0, 2.0, 3.0 ]
assert config.get_float_list('float_list.unset', '3.0 2.0 1.0') == [ 3.0, 2.0, 1.0 ]
assert config.get_float_list('float_list.unset') is None
assert config.get_float_list('float_list.invalid') is None
|