Fix ControlNetUnit copy issue (#2910)
* Fix ControlNetUnit copy issue * Add copy testpull/2912/head
parent
a5c0da5a23
commit
b197f7cc41
|
|
@ -471,3 +471,7 @@ class ControlNetUnit(BaseModel):
|
|||
for (key, value) in (item.strip().split(": "),)
|
||||
},
|
||||
)
|
||||
|
||||
def __copy__(self) -> ControlNetUnit:
|
||||
"""Override the behavior on `copy.copy` calls."""
|
||||
return self.copy()
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import pytest
|
||||
import torch
|
||||
import numpy as np
|
||||
from copy import copy
|
||||
from dataclasses import dataclass
|
||||
|
||||
from internal_controlnet.args import ControlNetUnit
|
||||
|
|
@ -249,3 +250,11 @@ def test_infotext_parsing():
|
|||
|
||||
def test_alias():
|
||||
ControlNetUnit.from_dict({"lowvram": True})
|
||||
|
||||
|
||||
def test_copy():
|
||||
unit1 = ControlNetUnit(enabled=True, module="none")
|
||||
unit2 = copy(unit1)
|
||||
unit2.enabled = False
|
||||
assert unit1.enabled
|
||||
assert not unit2.enabled
|
||||
|
|
|
|||
Loading…
Reference in New Issue