<commit_before># -*- coding: utf-8 -*-
'''
    :codeauthor: :email:`<NAME> <<EMAIL>>`
'''

# Import Salt Testing Libs
from salttesting import TestCase, skipIf
from salttesting.mock import (
    MagicMock,
    patch,
    NO_MOCK,
    NO_MOCK_REASON
)

# Import Salt Libs
from salt.modules import environ
import os


# Globals
environ.__grains__ = {}
environ.__salt__ = {}
environ.__context__ = {}


@skipIf(NO_MOCK, NO_MOCK_REASON)
class EnvironTestCase(TestCase):
    '''
    Test cases for salt.modules.environ
    '''
    def test_setval(self):
        '''
        Test for set a single salt process environment variable. Returns True
        on success.
        '''
        mock = MagicMock(return_value=None)
        with patch.dict(os.environ, {}):
            self.assertEqual(environ.setval('key', False, True), None)

        mock = MagicMock(side_effect=Exception())
        with patch.dict(os.environ, {}):
            self.assertFalse(environ.setval('key', False, True))

        mock_environ = {}
        with patch.dict(os.environ, mock_environ):
            self.assertEqual(environ.setval('key', False), '')

        with patch.dict(os.environ, mock_environ):
            self.assertFalse(environ.setval('key', True))

    def test_setenv(self):
        '''
        Set multiple salt process environment variables from a dict.
        Returns a dict.
        '''
        self.assertFalse(environ.setenv('environ'))

        self.assertFalse(environ.setenv({'A': True},
                                        False,
                                        True,
                                        False))

        mock_environ = {'key': 'value'}
        with patch.dict(os.environ, mock_environ):
            mock_setval = MagicMock(return_value=None)
            with patch.object(environ, 'setval', mock_setval):
                self.assertEqual(environ.setenv({}, False, True, False)['key'],
                                 None)<commit_msg>Fix sed test<commit_after># -*- coding: utf-8 -*-
'''
    :codeauthor: :email:`<NAME> <<EMAIL> <EMAIL>>`
'''

# Import Salt Testing Libs
from salttesting import TestCase, skipIf
from salttesting.mock import (
    MagicMock,
    patch,
    NO_MOCK,
    NO_MOCK_REASON
)

# Import Salt Libs
from salt.modules import environ
import os


# Globals
environ.__grains__ = {}
environ.__salt__ = {}
environ.__context__ = {}


@skipIf(NO_MOCK, NO_MOCK_REASON)
class EnvironTestCase(TestCase):
    '''
    Test cases for salt.modules.environ
    '''
    def test_setval(self):
        '''
        Test for set a single salt process environment variable. Returns True
        on success.
        '''
        mock = MagicMock(return_value=None)
        with patch.dict(os.environ, {}):
            self.assertEqual(environ.setval('key', False, True), None)

        mock = MagicMock(side_effect=Exception())
        with patch.dict(os.environ, {}):
            self.assertFalse(environ.setval('key', False, True))

        mock_environ = {}
        with patch.dict(os.environ, mock_environ):
            self.assertEqual(environ.setval('key', False), '')

        with patch.dict(os.environ, mock_environ):
            self.assertFalse(environ.setval('key', True))

    def test_setenv(self):
        '''
        Set multiple salt process environment variables from a dict.
        Returns a dict.
        '''
        mock_environ = {'key': 'value'}
        with patch.dict(os.environ, mock_environ):
            self.assertFalse(environ.setenv('environ'))

        with patch.dict(os.environ, mock_environ):
            self.assertFalse(environ.setenv({'A': True},
                                            False,
                                            True,
                                            False))

        with patch.dict(os.environ, mock_environ):
            mock_setval = MagicMock(return_value=None)
            with patch.object(environ, 'setval', mock_setval):
                self.assertEqual(environ.setenv({}, False, True, False)['key'],
                                 None)
{'fraction_non_alphanumeric': 0.12022665681202267, 'fraction_numerical': 0.0004927322000492732, 'mean_word_length': 2.0711043872919817, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 11, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3812218', 'n_tokens_mistral': 1135, 'n_tokens_neox': 1159, 'n_words': 250}