test_context.py 303 字节
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
import pytest
from ding.framework import Context
import pickle


@pytest.mark.unittest
def test_pickable():
    ctx = Context(hello="world", keep_me=True)
    ctx.keep("keep_me")
    _ctx = pickle.loads(pickle.dumps(ctx))
    assert _ctx.hello == "world"

    _ctx = ctx.renew()
    assert _ctx.keep_me