Compare commits
3 Commits
0.0.1.post
...
0.0.1.post
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
981c5201a9 | ||
|
|
ab11052c8f | ||
|
|
4f5dade949 |
@@ -13,6 +13,7 @@ Main module __init__ file.
|
||||
from .__metadata__ import __version__, __Summuary__, __Name__
|
||||
from .model import (
|
||||
DABFieldInfo,
|
||||
DABField,
|
||||
BaseAppliance,
|
||||
BaseFeature,
|
||||
DABModelException,
|
||||
@@ -27,4 +28,6 @@ from .model import (
|
||||
IncompletelyAnnotatedField,
|
||||
ImportForbidden,
|
||||
FunctionForbidden,
|
||||
FrozenDABField,
|
||||
InvalidFeatureInheritance,
|
||||
)
|
||||
|
||||
@@ -55,7 +55,6 @@ ALLOWED_ANNOTATIONS = {
|
||||
}
|
||||
|
||||
ALLOWED_MODEL_FIELDS_TYPES = (str, int, float, complex, bool, bytes)
|
||||
ALLOWED_MODEL_FIELDS_CONTAINERS = (dict, list, set, frozenset, tuple)
|
||||
|
||||
|
||||
# TV_ALLOWED_MODEL_FIELDS_TYPES = TypeVar("TV_ALLOWED_MODEL_FIELDS_TYPES", *ALLOWED_MODEL_FIELDS_TYPES, *ALLOWED_MODEL_FIELDS_CONTAINERS)
|
||||
@@ -66,7 +65,11 @@ class DABModelException(Exception):
|
||||
Base Exception for DABModelException class
|
||||
"""
|
||||
|
||||
|
||||
class ReservedFieldName(Exception):
|
||||
"""DABModelException Exception class
|
||||
Base Exception for DABModelException class
|
||||
"""
|
||||
|
||||
class MultipleInheritanceForbidden(DABModelException):
|
||||
"""MultipleInheritanceForbidden Exception class
|
||||
Multiple inheritance is forbidden when using dabmodel
|
||||
@@ -138,6 +141,10 @@ class ImportForbidden(DABModelException):
|
||||
Imports are forbidden
|
||||
"""
|
||||
|
||||
class InvalidFeatureInheritance(DABModelException):
|
||||
"""InvalidFeatureInheritance Exception class
|
||||
Features of same name in child appliance need to be from same type
|
||||
"""
|
||||
|
||||
class FunctionForbidden(DABModelException):
|
||||
"""FunctionForbidden Exception class
|
||||
@@ -473,7 +480,7 @@ class BaseMeta(type):
|
||||
mcs: type["BaseMeta"], name: str, bases: tuple[type[Any], ...], namespace: dict[str, Any] # pylint: disable=unused-argument
|
||||
) -> None:
|
||||
"""early BaseElement checks"""
|
||||
# print("__NEW__ Defining:", name, "with keys:", list(namespace))
|
||||
print("__NEW__ Defining:", name, "with keys:", list(namespace))
|
||||
|
||||
if len(bases) > 1:
|
||||
raise MultipleInheritanceForbidden("Multiple inheritance is not supported by dabmodel")
|
||||
@@ -529,9 +536,9 @@ class BaseMeta(type):
|
||||
mcs: type["BaseMeta"], name: str, bases: tuple[type[Any], ...], namespace: dict[str, Any], _fname: str, _fvalue: Any
|
||||
): # pylint: disable=unused-argument
|
||||
"""preprocessing BaseElement modified Fields"""
|
||||
# print(f"Modified field: {_fname}")
|
||||
print(f"Modified field: {_fname}")
|
||||
if "__annotations__" in namespace and _fname in namespace["__annotations__"]:
|
||||
raise ReadOnlyFieldAnnotation("annotations cannot be modified on derived classes")
|
||||
raise ReadOnlyFieldAnnotation(f"annotations cannot be modified on derived classes {_fname}")
|
||||
try:
|
||||
check_type(
|
||||
_fvalue,
|
||||
@@ -549,7 +556,7 @@ class BaseMeta(type):
|
||||
mcs: type["BaseMeta"], name: str, bases: tuple[type[Any], ...], namespace: dict[str, Any], _fname: str, _fvalue: Any
|
||||
): # pylint: disable=unused-argument
|
||||
"""preprocessing BaseElement new Fields"""
|
||||
# print(f"New field: {_fname}")
|
||||
print(f"New field: {_fname}")
|
||||
# print(f"type is: {type(_fvalue)}")
|
||||
# print(f"value is: {_fvalue}")
|
||||
|
||||
@@ -576,8 +583,7 @@ class BaseMeta(type):
|
||||
raise InvalidFieldAnnotation("Only DABFieldInfo object is allowed as Annotated data.")
|
||||
|
||||
_finfo = args[1]
|
||||
|
||||
# print(f"annotation is: {namespace['__annotations__'][_fname]}")
|
||||
|
||||
# check if value is valid
|
||||
try:
|
||||
check_type(_fvalue, namespace["__annotations__"][_fname], collection_check_strategy=CollectionCheckStrategy.ALL_ITEMS)
|
||||
@@ -594,8 +600,9 @@ class BaseMeta(type):
|
||||
init_fieldvalues = {}
|
||||
init_fieldtypes = {}
|
||||
for _fname, _fvalue in cls.__DABSchema__.items():
|
||||
init_fieldvalues[_fname] = deepcopy(_fvalue.raw_value)
|
||||
init_fieldtypes[_fname] = _fvalue.annotations
|
||||
if isinstance(_fvalue,DABField):
|
||||
init_fieldvalues[_fname] = deepcopy(_fvalue.raw_value)
|
||||
init_fieldtypes[_fname] = _fvalue.annotations
|
||||
fakecls = ModelSpecView(init_fieldvalues, init_fieldtypes, cls.__name__, cls.__module__)
|
||||
safe_globals = {"__builtins__": {"__import__": _blocked_import}, **ALLOWED_HELPERS_DEFAULT}
|
||||
if mcs.initializer.__code__.co_freevars:
|
||||
@@ -616,69 +623,149 @@ class BaseMeta(type):
|
||||
f"Value of Field <{_fname}> is not of expected type {namespace['__annotations__'][_fname]}."
|
||||
) from exp
|
||||
cls.__DABSchema__[_fname].update_value(_fvalue)
|
||||
|
||||
|
||||
def __new__(mcs: type["BaseMeta"], name: str, bases: tuple[type[Any], ...], namespace: dict[str, Any]) -> Type:
|
||||
"""BaseElement new class"""
|
||||
mcs.pre_check(name, bases, namespace)
|
||||
mcs.pre_processing(name, bases, namespace)
|
||||
|
||||
orig_setattr = namespace.get("__setattr__", object.__setattr__)
|
||||
|
||||
def guarded_setattr(self, key: str, value: Any):
|
||||
if key.startswith("_"): # allow private and dunder attrs
|
||||
return orig_setattr(self, key, value)
|
||||
# block writes after init if key is readonly
|
||||
if key in self.__DABSchema__.keys():
|
||||
if hasattr(self, key):
|
||||
raise ReadOnlyField(f"{key} is read-only")
|
||||
else:
|
||||
raise NewFieldForbidden("creating new fields is not allowed")
|
||||
|
||||
return orig_setattr(self, key, value)
|
||||
|
||||
namespace["__setattr__"] = guarded_setattr
|
||||
|
||||
|
||||
_cls = super().__new__(mcs, name, bases, namespace)
|
||||
|
||||
mcs.save_values(_cls, name, bases, namespace)
|
||||
mcs.call_initializer(_cls, name, bases, namespace)
|
||||
_cls.install_guard()
|
||||
|
||||
return _cls
|
||||
|
||||
@classmethod
|
||||
def save_values(
|
||||
mcs: type["BaseMeta"], cls, name: str, bases: tuple[type[Any], ...], namespace: dict[str, Any] # pylint: disable=unused-argument
|
||||
):
|
||||
for _fname, _fvalue in mcs.modified_field.items():
|
||||
_cls.__DABSchema__[_fname] = deepcopy(bases[0].__DABSchema__[_fname])
|
||||
_cls.__DABSchema__[_fname].update_value(_fvalue)
|
||||
cls.__DABSchema__[_fname] = deepcopy(bases[0].__DABSchema__[_fname])
|
||||
cls.__DABSchema__[_fname].update_value(_fvalue)
|
||||
|
||||
for _fname, _fvalue in mcs.new_fields.items():
|
||||
_fvalue.add_source(mcs)
|
||||
_cls.__DABSchema__[_fname] = _fvalue
|
||||
|
||||
mcs.call_initializer(_cls, name, bases, namespace)
|
||||
|
||||
return _cls
|
||||
|
||||
def __call__(cls, *args: Any, **kw: Any): # intentionally untyped
|
||||
cls.__DABSchema__[_fname] = _fvalue
|
||||
|
||||
def __call__(cls: Type, *args: Any, **kw: Any): # intentionally untyped
|
||||
"""BaseElement new instance"""
|
||||
obj = super().__call__(*args, **kw)
|
||||
|
||||
for _fname, _fvalue in cls.__DABSchema__.items():
|
||||
setattr(obj, _fname, _fvalue.value)
|
||||
inst_schema: dict[str, Any] = {}
|
||||
for _fname, _fvalue in cls.__DABSchema__.items():
|
||||
inst_schema[_fname] = FrozenDABField(_fvalue)
|
||||
setattr(obj, "__DABSchema__", inst_schema)
|
||||
return obj
|
||||
if isinstance(_fvalue,DABField):
|
||||
object.__setattr__(obj, _fname, _fvalue.value)
|
||||
|
||||
inst_schema = copy(obj.__DABSchema__)
|
||||
for _fname, _fvalue in cls.__DABSchema__.items():
|
||||
if isinstance(_fvalue,DABField):
|
||||
inst_schema[_fname] = FrozenDABField(_fvalue)
|
||||
|
||||
object.__setattr__(obj, "__DABSchema__", inst_schema)
|
||||
cls.modify_object(obj)
|
||||
|
||||
|
||||
return obj
|
||||
|
||||
def modify_object(cls:Type,obj):
|
||||
pass
|
||||
|
||||
|
||||
def install_guard(cls:Type):
|
||||
orig_setattr = getattr(cls,"__setattr__")
|
||||
|
||||
# cls.orig_setattr = orig_setattr
|
||||
|
||||
def guarded_setattr(_self, key: str, value: Any):
|
||||
if key.startswith("_"): # allow private and dunder attrs
|
||||
return orig_setattr(_self, key, value)
|
||||
# block writes after init if key is readonly
|
||||
if key in _self.__DABSchema__.keys():
|
||||
if key in _self.__dict__:
|
||||
raise ReadOnlyField(f"{key} is read-only")
|
||||
elif key in _self.__DABSchema__["features"].keys():
|
||||
if key in _self.__dict__:
|
||||
raise ReadOnlyField(f"{key} is read-only")
|
||||
else:
|
||||
raise NewFieldForbidden("creating new fields is not allowed")
|
||||
|
||||
return orig_setattr(_self, key, value)
|
||||
|
||||
setattr(cls, "__setattr__", guarded_setattr)
|
||||
|
||||
class BaseElement(metaclass=BaseMeta):
|
||||
"""BaseElement class
|
||||
Base class to apply metaclass and set common Fields.
|
||||
"""
|
||||
|
||||
class BaseMetaFeature(BaseMeta):
|
||||
pass
|
||||
|
||||
class BaseFeature(BaseElement):
|
||||
class BaseFeature(BaseElement,metaclass=BaseMetaFeature):
|
||||
"""BaseFeature class
|
||||
Base class for Appliance's Features.
|
||||
Features are optional traits of an appliance.
|
||||
"""
|
||||
Enabled:bool=False
|
||||
|
||||
class BaseMetaAppliance(BaseMeta):
|
||||
|
||||
@classmethod
|
||||
def pre_check(
|
||||
mcs: type["BaseMeta"], name: str, bases: tuple[type[Any], ...], namespace: dict[str, Any] # pylint: disable=unused-argument
|
||||
) -> None:
|
||||
"""early BaseElement checks"""
|
||||
print("__NEW__ Defining:", name, "with keys:", list(namespace))
|
||||
super().pre_check(name,bases,namespace)
|
||||
if "features" not in namespace["__DABSchema__"]:
|
||||
namespace["__DABSchema__"]["features"]={}
|
||||
else:
|
||||
namespace["__DABSchema__"]["features"] = copy(namespace["__DABSchema__"]["features"])
|
||||
return
|
||||
|
||||
|
||||
class BaseAppliance(BaseElement):
|
||||
@classmethod
|
||||
def pre_processing(mcs: type["BaseMeta"], name: str, bases: tuple[type[Any], ...], namespace: dict[str, Any]):
|
||||
mcs.new_features: dict[str,type[BaseFeature]] = {}
|
||||
mcs.modified_features: dict[str,type[BaseFeature]] = {}
|
||||
super().pre_processing(name,bases,namespace)
|
||||
|
||||
@classmethod
|
||||
def pre_processing_new_fields(
|
||||
mcs: type["BaseMeta"], name: str, bases: tuple[type[Any], ...], namespace: dict[str, Any], _fname: str, _fvalue: Any
|
||||
): # pylint: disable=unused-argument
|
||||
"""preprocessing BaseElement new Fields"""
|
||||
print('pre_processing_new_fields')
|
||||
if _fname in namespace["__DABSchema__"]["features"].keys():
|
||||
print("existing Feature !")
|
||||
if not issubclass(_fvalue,namespace["__DABSchema__"]["features"][_fname]):
|
||||
raise InvalidFeatureInheritance(f"Feature {_fname} is not an instance of {bases[0]}.{_fname}")
|
||||
mcs.modified_features[_fname]=_fvalue
|
||||
elif isinstance(_fvalue,BaseMetaFeature):
|
||||
print("find Feature")
|
||||
mcs.new_features[_fname]=_fvalue
|
||||
else:
|
||||
super().pre_processing_new_fields(name,bases,namespace,_fname,_fvalue)
|
||||
|
||||
@classmethod
|
||||
def save_values(
|
||||
mcs: type["BaseMeta"], cls, name: str, bases: tuple[type[Any], ...], namespace: dict[str, Any] # pylint: disable=unused-argument
|
||||
):
|
||||
super().save_values(cls,name,bases,namespace)
|
||||
print(dir(mcs))
|
||||
for _ftname,_ftvalue in mcs.modified_features.items():
|
||||
cls.__DABSchema__["features"][_ftname] = _ftvalue
|
||||
for _ftname,_ftvalue in mcs.new_features.items():
|
||||
cls.__DABSchema__["features"][_ftname] = _ftvalue
|
||||
|
||||
def modify_object(cls:Type, obj): # intentionally untyped
|
||||
for _ftname,_ftvalue in cls.__DABSchema__["features"].items():
|
||||
instft = _ftvalue()
|
||||
object.__setattr__(obj, _ftname,instft )
|
||||
|
||||
|
||||
class BaseAppliance(BaseElement,metaclass=BaseMetaAppliance):
|
||||
"""BaseFeature class
|
||||
Base class for Appliance.
|
||||
An appliance is a server configuration / image that is built using appliance's code and Fields.
|
||||
|
||||
@@ -31,7 +31,7 @@ def test_initializer_safe_testfc():
|
||||
eval("print('hi')")
|
||||
|
||||
|
||||
class TestConfigWithoutEnabledFlag(unittest.TestCase):
|
||||
class MainTests(unittest.TestCase):
|
||||
def setUp(self):
|
||||
print("\n->", unittest.TestCase.id(self))
|
||||
|
||||
@@ -219,7 +219,7 @@ class TestConfigWithoutEnabledFlag(unittest.TestCase):
|
||||
self.immutable_vars__test_field(app2, "StrVar5", "default value", "123")
|
||||
self.immutable_vars__test_field(app2, "StrVar6", None, "123")
|
||||
|
||||
# @unittest.skip
|
||||
@unittest.skip
|
||||
def test_containers__set(self):
|
||||
"""Testing first appliance level, and Field types (Set)"""
|
||||
|
||||
@@ -298,7 +298,7 @@ class TestConfigWithoutEnabledFlag(unittest.TestCase):
|
||||
res = subprocess.run([sys.executable, "-c", code], env=env)
|
||||
self.assertEqual(res.returncode, 2)
|
||||
|
||||
# @unittest.skip
|
||||
@unittest.skip
|
||||
def test_containers__frozenset(self):
|
||||
"""Testing first appliance level, and Field types (FrozenSet)"""
|
||||
|
||||
@@ -1175,7 +1175,179 @@ class TestConfigWithoutEnabledFlag(unittest.TestCase):
|
||||
def __initializer(cls):
|
||||
test_initializer_safe_testfc()
|
||||
|
||||
def test_feature(self):
|
||||
"""Testing first appliance feature, and Field types (simple)"""
|
||||
|
||||
|
||||
|
||||
# class can be created
|
||||
class Appliance1(dm.BaseAppliance):
|
||||
VarStrOuter: str = "testvalue APPLIANCE"
|
||||
class Feature1(dm.BaseFeature):
|
||||
VarStrInner: str = "testvalue FEATURE"
|
||||
app1 = Appliance1()
|
||||
|
||||
self.assertIsInstance(Appliance1.__DABSchema__["VarStrOuter"],dm.DABField)
|
||||
self.assertIsInstance(app1.__DABSchema__["VarStrOuter"],dm.FrozenDABField)
|
||||
self.assertIn("Feature1",app1.__DABSchema__["features"])
|
||||
self.assertIn("VarStrInner",app1.__DABSchema__["features"]["Feature1"].__DABSchema__)
|
||||
self.assertIsInstance(app1.__DABSchema__["features"]["Feature1"].__DABSchema__["VarStrInner"],dm.DABField)
|
||||
self.assertTrue(hasattr(app1, "Feature1"))
|
||||
self.assertIsInstance(app1.Feature1.__DABSchema__["VarStrInner"],dm.FrozenDABField)
|
||||
self.assertTrue(hasattr(app1.Feature1, "VarStrInner"))
|
||||
|
||||
def test_feature_inheritance(self):
|
||||
"""Testing first appliance feature, and Field types (simple)"""
|
||||
|
||||
|
||||
|
||||
# class can be created
|
||||
class Appliance1(dm.BaseAppliance):
|
||||
VarStrOuter: str = "testvalue APPLIANCE1"
|
||||
class Feature1(dm.BaseFeature):
|
||||
VarStrInner: str = "testvalue FEATURE1"
|
||||
VarInt:int=42
|
||||
|
||||
print(dir(Appliance1))
|
||||
|
||||
class Appliance2(Appliance1):
|
||||
VarStrOuter = "testvalue APPLIANCE2"
|
||||
class Feature2(dm.BaseFeature):
|
||||
VarStrInner: str = "testvalue FEATURE2"
|
||||
|
||||
print(dir(Appliance2))
|
||||
|
||||
class Appliance3(Appliance2):
|
||||
VarStrOuter = "testvalue APPLIANCE3"
|
||||
class Feature1(Appliance1.Feature1):
|
||||
VarStrInner = "testvalue FEATURE1 modded"
|
||||
class Feature3(dm.BaseFeature):
|
||||
VarStrInner: str = "testvalue FEATURE3"
|
||||
|
||||
print(dir(Appliance3))
|
||||
|
||||
app1 = Appliance1()
|
||||
app2 = Appliance2()
|
||||
app3 = Appliance3()
|
||||
|
||||
self.assertIsInstance(Appliance1.__DABSchema__["VarStrOuter"],dm.DABField)
|
||||
self.assertIsInstance(app1.__DABSchema__["VarStrOuter"],dm.FrozenDABField)
|
||||
self.assertIn("Feature1",app1.__DABSchema__["features"])
|
||||
self.assertIn("VarStrInner",app1.__DABSchema__["features"]["Feature1"].__DABSchema__)
|
||||
self.assertIsInstance(app1.__DABSchema__["features"]["Feature1"].__DABSchema__["VarStrInner"],dm.DABField)
|
||||
self.assertTrue(hasattr(app1, "Feature1"))
|
||||
self.assertIsInstance(app1.Feature1.__DABSchema__["VarStrInner"],dm.FrozenDABField)
|
||||
self.assertTrue(hasattr(app1.Feature1, "VarStrInner"))
|
||||
self.assertEqual(app1.VarStrOuter,"testvalue APPLIANCE1")
|
||||
self.assertEqual(app1.Feature1.VarStrInner,"testvalue FEATURE1")
|
||||
self.assertEqual(app1.Feature1.VarInt,42)
|
||||
self.assertEqual(app2.VarStrOuter,"testvalue APPLIANCE2")
|
||||
self.assertEqual(app2.Feature2.VarStrInner,"testvalue FEATURE2")
|
||||
self.assertEqual(app3.VarStrOuter,"testvalue APPLIANCE3")
|
||||
self.assertEqual(app3.Feature1.VarStrInner,"testvalue FEATURE1 modded")
|
||||
self.assertEqual(app3.Feature1.VarInt,42)
|
||||
self.assertEqual(app3.Feature3.VarStrInner,"testvalue FEATURE3")
|
||||
|
||||
def test_feature_inheritance2(self):
|
||||
"""Testing first appliance feature, and Field types (simple)"""
|
||||
|
||||
# class can be created
|
||||
class Appliance1(dm.BaseAppliance):
|
||||
class Feature1(dm.BaseFeature):
|
||||
VarStrInner: str = "testvalue FEATURE1"
|
||||
|
||||
# check cannot REdefine a feature from BaseFeature
|
||||
with self.assertRaises(dm.InvalidFeatureInheritance):
|
||||
class Appliance2(Appliance1):
|
||||
class Feature1(dm.BaseFeature):
|
||||
...
|
||||
|
||||
class Appliance2b(Appliance1):
|
||||
class Feature1(Appliance1.Feature1):
|
||||
...
|
||||
|
||||
# check only REdefine a feature from direct parent
|
||||
with self.assertRaises(dm.InvalidFeatureInheritance):
|
||||
class Appliance3(Appliance2b):
|
||||
class Feature1(Appliance1.Feature1):
|
||||
...
|
||||
|
||||
class Appliance3b(Appliance2b):
|
||||
class Feature1(Appliance2b.Feature1):
|
||||
...
|
||||
|
||||
app1 = Appliance1()
|
||||
app2 = Appliance2b()
|
||||
|
||||
print("youhou1")
|
||||
print(Appliance3b)
|
||||
print(Appliance3b.Feature1)
|
||||
print("=====")
|
||||
|
||||
app3 = Appliance3b()
|
||||
|
||||
print("youhou2")
|
||||
print(Appliance3b)
|
||||
print(Appliance3b.Feature1)
|
||||
print("=====")
|
||||
|
||||
#self.assertEqual(app1.Feature1.VarStrInner,"testvalue FEATURE1")
|
||||
#self.assertEqual(app2.Feature1.VarStrInner,"testvalue FEATURE1")
|
||||
#self.assertEqual(app3.Feature1.VarStrInner,"testvalue FEATURE1")
|
||||
|
||||
class Appliance4(Appliance3b):
|
||||
class Feature1(Appliance3b.Feature1):
|
||||
VarStrInner = "testvalue FEATURE4"
|
||||
|
||||
self.assertEqual(app1.Feature1.VarStrInner,"testvalue FEATURE1")
|
||||
self.assertEqual(app2.Feature1.VarStrInner,"testvalue FEATURE1")
|
||||
self.assertEqual(app3.Feature1.VarStrInner,"testvalue FEATURE1")
|
||||
|
||||
app4 = Appliance4()
|
||||
|
||||
self.assertEqual(app1.Feature1.VarStrInner,"testvalue FEATURE1")
|
||||
self.assertEqual(app2.Feature1.VarStrInner,"testvalue FEATURE1")
|
||||
self.assertEqual(app3.Feature1.VarStrInner,"testvalue FEATURE1")
|
||||
self.assertEqual(app4.Feature1.VarStrInner,"testvalue FEATURE4")
|
||||
|
||||
def test_inheritance_chain(self):
|
||||
|
||||
# class can be created
|
||||
class Appliance1(dm.BaseAppliance):
|
||||
VarStr: str = "testvalue1"
|
||||
|
||||
class Appliance2(Appliance1):
|
||||
pass
|
||||
|
||||
class Appliance3(Appliance2):
|
||||
pass
|
||||
|
||||
app1 = Appliance1()
|
||||
app2 = Appliance2()
|
||||
app3 = Appliance3()
|
||||
|
||||
self.assertEqual(app1.VarStr,"testvalue1")
|
||||
self.assertEqual(app2.VarStr,"testvalue1")
|
||||
self.assertEqual(app3.VarStr,"testvalue1")
|
||||
|
||||
class Appliance4(Appliance3):
|
||||
VarStr = "testvalue moded"
|
||||
|
||||
|
||||
app4 = Appliance4()
|
||||
|
||||
self.assertEqual(app1.VarStr,"testvalue1")
|
||||
self.assertEqual(app2.VarStr,"testvalue1")
|
||||
self.assertEqual(app3.VarStr,"testvalue1")
|
||||
self.assertEqual(app4.VarStr,"testvalue moded")
|
||||
|
||||
app1b = Appliance1()
|
||||
app2b = Appliance2()
|
||||
app3b = Appliance3()
|
||||
self.assertEqual(app1b.VarStr,"testvalue1")
|
||||
self.assertEqual(app2b.VarStr,"testvalue1")
|
||||
self.assertEqual(app3b.VarStr,"testvalue1")
|
||||
|
||||
# ---------- main ----------
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user