import unittest
import functools


def skip_if_abstract(func):
    """Decorator function to keep :py:mod:`unittest` from running methods
    (defined in abstract classes) that are only intended to be run when
    inherited by fully-fleshed out subclasses. Wrapped methods are actually
    called from all non-abstract subclasses that inherit the method.
    
    Parameters
    ----------
    func : function
        Function that should only be run in a non-abstract subclass

    Returns
    -------
    function
        wrapped function
    """

    @functools.wraps(func)
    def new_func(*args, **kwargs):
        if "Abstract" in args[0].__class__.__name__:
            return unittest.skip(
                "Skipping all tests from abstract class (don't worry, this is expected)."
            )(
                func
            )
        else:
            return func(*args, **kwargs)

    return new_func