# 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
        self.i = i

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

    a = A(i=0)
    assert a.i == 0


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

    @A.behavior
    def my_fun(self, i):
        return i + 1

    a = A()
    x = 1
    with pytest.raises(NotImplementedError):
        run(a)

    # We add the behavior *after* the instance creation
    @main
    @A.behavior
    def entry_point(self, i=0):
        return self.my_fun(i)


# 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

        self.i = i

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

    a = A(i=0)
    assert a.i == 0


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

    @A.behavior
    def my_fun(self, i):
        return i + 1

    a = A()
    x = 1
    with pytest.raises(NotImplementedError):
        run(a)

    # We add the behavior *after* the instance creation
    @main
    @A.behavior
    def entry_point(self, i=0):
        return self.my_fun(i)


    y = run(a, x)