<commit_before># -*- coding: utf-8 -*-
'''
Test States
==================

Provide test case states that enable easy testing of things to do with
 state calls, e.g. running, calling, logging, output filtering etc.

.. code-block:: yaml

    always-passes:
      test.succeed_without_changes:
        - name: foo

    always-fails:
      test.fail_without_changes:
        - name: foo

    always-changes-and-succeeds:
      test.succeed_with_changes:
        - name: foo

    always-changes-and-fails:
      test.fail_with_changes:
        - name: foo

    my-custom-combo:
      test.configurable_test_state:
        - name: foo
        - changes: True
        - result: False
        - comment: bar.baz

'''

# Import Python libs
import logging
import random
from salt.exceptions import SaltInvocationError

log = logging.getLogger(__name__)


def succeed_without_changes(name):
    '''
    Returns successful.

    .. versionadded:: Helium

    name
        A unique string.
    '''
    ret = {
        'name': name,
        'changes': {},
        'result': True,
        'comment': 'Success!'
    }
    if __opts__['test']:
        ret['result'] = None
        ret['comment'] = 'If we weren\'t testing, this would be a success!'
    return ret


def fail_without_changes(name):
    '''
    Returns failure.

    .. versionadded:: Helium

    name:
        A unique string.
    '''
    ret = {
        'name': name,
        'changes': {},
        'result': False,
        'comment': 'Failure!'
    }

    if __opts__['test']:
        ret['result'] = None
        ret['comment'] = 'If we weren\'t testing, this would be a failure!'

    return ret<commit_msg>Fix test=True for states without changes<commit_after># -*- coding: utf-8 -*-
'''
Test States
==================

Provide test case states that enable easy testing of things to do with
 state calls, e.g. running, calling, logging, output filtering etc.

.. code-block:: yaml

    always-passes:
      test.succeed_without_changes:
        - name: foo

    always-fails:
      test.fail_without_changes:
        - name: foo

    always-changes-and-succeeds:
      test.succeed_with_changes:
        - name: foo

    always-changes-and-fails:
      test.fail_with_changes:
        - name: foo

    my-custom-combo:
      test.configurable_test_state:
        - name: foo
        - changes: True
        - result: False
        - comment: bar.baz

'''

# Import Python libs
import logging
import random
from salt.exceptions import SaltInvocationError

log = logging.getLogger(__name__)


def succeed_without_changes(name):
    '''
    Returns successful.

    .. versionadded:: Helium

    name
        A unique string.
    '''
    ret = {
        'name': name,
        'changes': {},
        'result': True,
        'comment': 'Success!'
    }
    if __opts__['test']:
        ret['result'] = True
        ret['comment'] = 'If we weren\'t testing, this would be a success!'
    return ret


def fail_without_changes(name):
    '''
    Returns failure.

    .. versionadded:: Helium

    name:
        A unique string.
    '''
    ret = {
        'name': name,
        'changes': {},
        'result': False,
        'comment': 'Failure!'
    }

    if __opts__['test']:
        ret['result'] = False
        ret['comment'] = 'If we weren\'t testing, this would be a failure!'

    return ret
{'fraction_non_alphanumeric': 0.12865671641791046, 'fraction_numerical': 0.0005970149253731343, 'mean_word_length': 2.1143122676579926, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4290757', 'n_tokens_mistral': 1026, 'n_tokens_neox': 989, 'n_words': 276}