# Path: pyecore/behavior.py
# def behavior(cls):
#     def inner_decorator(fun):
#         if isinstance(cls, type):
#             setattr(cls, fun.__name__, fun)
#         else:
#             setattr(cls.python_class, fun.__name__, fun)
#         return fun
#     return inner_decorator
# 
# def main(fun):
#     fun.main = True
#     return fun
# 
# def run(eclass, *args, **kwargs):
#     cls = eclass.eClass.python_class
#     for _, attr in cls.__dict__.items():
#         if inspect.isfunction(attr) and getattr(attr, 'main', False):
#             return attr(eclass, *args, **kwargs)
#     raise NotImplementedError(f'No @main entry point found for {cls}')


import pytest
from pyecore.ecore import *
from pyecore.behavior import behavior, main, run


def test_static_metamodel_behavior_injection():
    @EMetaclass
    class A(object):
        pass

    @A.behavior
    def my_fun(self):
        return True

    @A.behavior
    def __init__(self, i=15):
        self.i = i

    a = A()
    assert a.my_fun() is True

# Path: pyecore/behavior.py
# def behavior(cls):
#     def inner_decorator(fun):
#         if isinstance(cls, type):
#             setattr(cls, fun.__name__, fun)
#         else:
#             setattr(cls.python_class, fun.__name__, fun)
#         return fun
#     return inner_decorator
# 
# def main(fun):
#     fun.main = True
#     return fun
# 
# def run(eclass, *args, **kwargs):
#     cls = eclass.eClass.python_class
#     for _, attr in cls.__dict__.items():
#         if inspect.isfunction(attr) and getattr(attr, 'main', False):
#             return attr(eclass, *args, **kwargs)
#     raise NotImplementedError(f'No @main entry point found for {cls}')


# Path: tests/test_behavior.py
import pytest
from pyecore.ecore import *
from pyecore.behavior import behavior, main, run



def test_static_metamodel_behavior_injection():
    @EMetaclass
    class A(object):
        pass

    @A.behavior
    def my_fun(self):
        return True

    @A.behavior
    def __init__(self, i=15):
        self.i = i

    a = A()
    assert a.my_fun() is True

    assert a.i == 15