Skip to content

Useful Types

API

CustomTestFn

Bases: Protocol

The function type to be called for custom tests.

Source code in src/gapper/core/types.py
class CustomTestFn(Protocol):
    """The function type to be called for custom tests."""

    def __call__[T](self, data: CustomTestData[T]) -> None:
        """Implement.

        :param data: The CustomTestData instance.
        :raises AssertionError: It should raise assertion error if test fails.
        """
        ...

__call__

__call__(data: CustomTestData[T]) -> None

Implement.

Parameters:

Name Type Description Default
data CustomTestData[T]

The CustomTestData instance.

required

Raises:

Type Description
AssertionError

It should raise assertion error if test fails.

Source code in src/gapper/core/types.py
def __call__[T](self, data: CustomTestData[T]) -> None:
    """Implement.

    :param data: The CustomTestData instance.
    :raises AssertionError: It should raise assertion error if test fails.
    """
    ...

CustomTestData dataclass

Bases: _TCMixin, _SolSubMixin[T]

Source code in src/gapper/core/types.py
@dataclass
class CustomTestData[T](_TCMixin, _SolSubMixin[T]):
    case: TestCaseWrapper
    result_proxy: TestResult
    solution: T
    submission: T

CustomEqualityCheckFn

Bases: Protocol

The function type to be called for custom equality checks.

Source code in src/gapper/core/types.py
class CustomEqualityCheckFn(Protocol):
    """The function type to be called for custom equality checks."""

    def __call__[T](self, data: CustomEqualityTestData[T]) -> None:
        """Implement.

        :param data: The CustomEqualityTestData instance.
        :raises AssertionError: It should raise assertion error if the equality check tails
        """
        ...

__call__

__call__(data: CustomEqualityTestData[T]) -> None

Implement.

Parameters:

Name Type Description Default
data CustomEqualityTestData[T]

The CustomEqualityTestData instance.

required

Raises:

Type Description
AssertionError

It should raise assertion error if the equality check tails

Source code in src/gapper/core/types.py
def __call__[T](self, data: CustomEqualityTestData[T]) -> None:
    """Implement.

    :param data: The CustomEqualityTestData instance.
    :raises AssertionError: It should raise assertion error if the equality check tails
    """
    ...

CustomEqualityTestData dataclass

Source code in src/gapper/core/types.py
@dataclass
class CustomEqualityTestData[T]:
    expected: T
    actual: T
    msg: str | None = field(default=None)

PreHookFn

Bases: Protocol

The function type to be called for post checks all the equality check of a test case.

Source code in src/gapper/core/types.py
class PreHookFn(Protocol):
    """The function type to be called for post checks all the equality check of a test case."""

    def __call__[T](self, data: PreHookData[T]) -> None:
        """Implement.

        :param data: The PreTestHookData instance.
        :raises AssertionError: It should raise assertion error if the pre hook fails.
        """
        ...

__call__

__call__(data: PreHookData[T]) -> None

Implement.

Parameters:

Name Type Description Default
data PreHookData[T]

The PreTestHookData instance.

required

Raises:

Type Description
AssertionError

It should raise assertion error if the pre hook fails.

Source code in src/gapper/core/types.py
def __call__[T](self, data: PreHookData[T]) -> None:
    """Implement.

    :param data: The PreTestHookData instance.
    :raises AssertionError: It should raise assertion error if the pre hook fails.
    """
    ...

PreHookData dataclass

Bases: HookDataBase, _TCMixin, _SolSubMixin[T]

Source code in src/gapper/core/types.py
@dataclass
class PreHookData[T](HookDataBase, _TCMixin, _SolSubMixin[T]):
    case: TestCaseWrapper
    result_proxy: TestResult
    solution: T
    submission: T

PostHookFn

Bases: Protocol

The function type to be called for post checks all the equality check of a test case.

Source code in src/gapper/core/types.py
class PostHookFn(Protocol):
    """The function type to be called for post checks all the equality check of a test case."""

    def __call__[T](self, data: PostHookData[T]) -> None:
        """Implement.

        :param data: The PostTestHookData instance.
        :raises AssertionError: It should raise assertion error if the post hook fails.
        """
        ...

__call__

__call__(data: PostHookData[T]) -> None

Implement.

Parameters:

Name Type Description Default
data PostHookData[T]

The PostTestHookData instance.

required

Raises:

Type Description
AssertionError

It should raise assertion error if the post hook fails.

Source code in src/gapper/core/types.py
def __call__[T](self, data: PostHookData[T]) -> None:
    """Implement.

    :param data: The PostTestHookData instance.
    :raises AssertionError: It should raise assertion error if the post hook fails.
    """
    ...

PostHookData dataclass

Bases: HookDataBase, _TCMixin, _SolSubMixin[T], _SolSubResultMixin[T]

Source code in src/gapper/core/types.py
@dataclass
class PostHookData[T](HookDataBase, _TCMixin, _SolSubMixin[T], _SolSubResultMixin[T]):
    case: TestCaseWrapper
    result_proxy: TestResult
    solution: T
    submission: T
    expected_results: ResultBundle
    actual_results: ResultBundle

PreTestsFn

Bases: Protocol

Source code in src/gapper/core/types.py
class PreTestsFn(Protocol):
    def __call__(self, data: PreTestsData) -> None:
        """Implement.

        :param data: The PreTestsData instance.
        :raises AssertionError: It should raise assertion error if the pre tests hook fail.
        """

__call__

__call__(data: PreTestsData) -> None

Implement.

Parameters:

Name Type Description Default
data PreTestsData

The PreTestsData instance.

required

Raises:

Type Description
AssertionError

It should raise assertion error if the pre tests hook fail.

Source code in src/gapper/core/types.py
def __call__(self, data: PreTestsData) -> None:
    """Implement.

    :param data: The PreTestsData instance.
    :raises AssertionError: It should raise assertion error if the pre tests hook fail.
    """

PreTestsData dataclass

Bases: HookDataBase

Source code in src/gapper/core/types.py
@dataclass
class PreTestsData[T](HookDataBase):
    result_proxy: TestResult | None = field(default=None)
    metadata: GradescopeSubmissionMetadata | None = field(default=None)

PostTestsFn

Bases: Protocol

The function type to be called after all tests are run.

Source code in src/gapper/core/types.py
class PostTestsFn(Protocol):
    """The function type to be called after all tests are run."""

    def __call__(self, data: PostTestsData) -> None:
        """Implement.

        :param data: The PostTestsData instance.
        :raises AssertionError: It should raise assertion error if the post tests hook fail.
        """
        ...

__call__

__call__(data: PostTestsData) -> None

Implement.

Parameters:

Name Type Description Default
data PostTestsData

The PostTestsData instance.

required

Raises:

Type Description
AssertionError

It should raise assertion error if the post tests hook fail.

Source code in src/gapper/core/types.py
def __call__(self, data: PostTestsData) -> None:
    """Implement.

    :param data: The PostTestsData instance.
    :raises AssertionError: It should raise assertion error if the post tests hook fail.
    """
    ...

PostTestsData dataclass

Bases: HookDataBase

Source code in src/gapper/core/types.py
@dataclass
class PostTestsData[T](HookDataBase):
    test_results: List[TestResult]
    result_proxy: TestResult | None = field(default=None)
    metadata: GradescopeSubmissionMetadata | None = field(default=None)