Esempio n. 1
0
    def make_session(self, name, func):
        """Create a session object from the session function.

        Args:
            name (str): The name of the session.
            func (function): The session function.

        Returns:
            Sequence[~nox.session.Session]: A sequence of Session objects
                bound to this manifest and configuration.
        """
        # Simple case: If this function is not parametrized, then make
        # a simple session
        if not hasattr(func, 'parametrize'):
            session = Session(name, None, func, self._config, self)
            return (session, )

        # Since this function is parametrized, we need to add a distinct
        # session for each permutation.
        sessions = []
        calls = generate_calls(func, func.parametrize)
        for call in calls:
            long_name = name + call.session_signature
            sessions.append(Session(name, long_name, call, self._config, self))

        # Edge case: If the parameters made it such that there were no valid
        # calls, add an empty, do-nothing session.
        if not calls:
            sessions.append(
                Session(name, None, _null_session_func, self._config, self), )

        # Return the list of sessions.
        return sessions
Esempio n. 2
0
File: main.py Progetto: tseaver/nox
def make_sessions(session_functions, global_config):
    """Create session objects from the session functions and the global
    configuration."""
    sessions = []
    for name, func in session_functions.items():
        if not hasattr(func, 'parametrize'):
            sessions.append(Session(name, None, func, global_config))
        else:
            calls = generate_calls(func, func.parametrize)
            for call in calls:
                session = Session(name, name + call.session_signature, call,
                                  global_config)
                sessions.append(session)
            if not calls:
                # Add an empty, do-nothing session.
                sessions.append(
                    Session(name, None, _null_session_func, global_config))

    return sessions