mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 11:18:54 -05:00
Test implicit subclass type conversion in config defaults/sets (#5874)
Co-authored-by: Jakub Kuczys <me@jacken.men>
This commit is contained in:
parent
19ebd02595
commit
0e97c26b2d
@ -1,6 +1,7 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
import pytest
|
import pytest
|
||||||
|
from collections import Counter
|
||||||
|
|
||||||
|
|
||||||
# region Register Tests
|
# region Register Tests
|
||||||
@ -593,6 +594,21 @@ async def test_raw_with_partial_primary_keys(config):
|
|||||||
assert await config.custom("CUSTOM", "primary_key").identifier() is False
|
assert await config.custom("CUSTOM", "primary_key").identifier() is False
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_cast_subclass_default(config):
|
||||||
|
# regression test for GH-5557/GH-5585
|
||||||
|
config.register_global(foo=Counter({}))
|
||||||
|
assert type(config.defaults["GLOBAL"]["foo"]) is dict
|
||||||
|
assert config.defaults["GLOBAL"]["foo"] == {}
|
||||||
|
stored_value = await config.foo()
|
||||||
|
assert type(stored_value) is dict
|
||||||
|
assert stored_value == {}
|
||||||
|
await config.foo.set(Counter({"bar": 1}))
|
||||||
|
stored_value = await config.foo()
|
||||||
|
assert type(stored_value) is dict
|
||||||
|
assert stored_value == {"bar": 1}
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Following PARAMS can be generated with:
|
Following PARAMS can be generated with:
|
||||||
from functools import reduce
|
from functools import reduce
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user