<commit_before># -*- coding: utf-8 -*-
"""
Tests for runner_returns
"""
from __future__ import absolute_import, print_function, unicode_literals

import errno
import os
import socket
import tempfile

import pytest
import salt.payload
import salt.utils.args
import salt.utils.files
import salt.utils.jid
import salt.utils.yaml
from tests.support.case import ShellCase
from tests.support.helpers import slowTest
from tests.support.runtests import RUNTIME_VARS


@pytest.mark.windows_whitelisted
class RunnerReturnsTest(ShellCase):
    """
    Test the "runner_returns" feature
    """

    def setUp(self):
        """
        Create the temp file and master.d directory
        """
        self.job_dir = os.path.join(self.master_opts["cachedir"], "jobs")
        self.hash_type = self.master_opts["hash_type"]
        self.master_d_dir = os.path.join(self.config_dir, "master.d")
        try:
            os.makedirs(self.master_d_dir)
        except OSError as exc:
            if exc.errno != errno.EEXIST:
                raise

        self.conf = tempfile.NamedTemporaryFile(
            mode="w", suffix=".conf", dir=self.master_d_dir, delete=False,
        )

    def tearDown(self):
        """
        Close the tempfile.NamedTemporaryFile object, cleaning it up
        """
        salt.utils.files.rm_rf(self.master_d_dir)
        # Force a reload of the configuration now that our temp config file has
        # been removed.
        self.run_run_plus("test.arg")

    @staticmethod
    def clean_return(data):
        """
        Remove kwargs and timestamp (things that are variable) so we have a
        stable value to assert
        """
        # Remove pub_kwargs
        data["fun_args"][1] = salt.utils.args.clean_kwargs(**data["fun_args"][1])
        data["return"]["kwargs"] = salt.utils.args.clean_kwargs(<commit_msg>Fix runner tests on windows<commit_after># -*- coding: utf-8 -*-
"""
Tests for runner_returns
"""
from __future__ import absolute_import, print_function, unicode_literals

import errno
import os
import socket
import tempfile

import pytest
import salt.payload
import salt.utils.args
import salt.utils.files
import salt.utils.jid
import salt.utils.yaml
from tests.support.case import ShellCase
from tests.support.helpers import slowTest
from tests.support.runtests import RUNTIME_VARS


@pytest.mark.windows_whitelisted
class RunnerReturnsTest(ShellCase):
    """
    Test the "runner_returns" feature
    """

    def setUp(self):
        """
        Create the temp file and master.d directory
        """
        self.job_dir = os.path.join(self.master_opts["cachedir"], "jobs")
        self.hash_type = self.master_opts["hash_type"]
        self.master_d_dir = os.path.join(self.config_dir, "master.d")
        try:
            os.makedirs(self.master_d_dir)
        except OSError as exc:
            if exc.errno != errno.EEXIST:
                raise

        self.conf = tempfile.NamedTemporaryFile(
            mode="w", suffix=".conf", dir=self.master_d_dir, delete=False,
        )

    def tearDown(self):
        """
        Close the tempfile.NamedTemporaryFile object, cleaning it up
        """
        try:
            self.conf.close()
        except OSError:
            pass
        salt.utils.files.rm_rf(self.master_d_dir)
        # Force a reload of the configuration now that our temp config file has
        # been removed.
        self.run_run_plus("test.arg")

    @staticmethod
    def clean_return(data):
        """
        Remove kwargs and timestamp (things that are variable) so we have a
        stable value to assert
        """
        # Remove pub_kwargs
        data["fun_args"][1] = salt.utils.args.clean_kwargs(**data["fun_args"][1])
        data["return"]["kwargs"] = salt.utils.args.clean_kwargs(
{'fraction_non_alphanumeric': 0.10375860243515088, 'fraction_numerical': 0.0015881418740074113, 'mean_word_length': 2.640655105973025, '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': '2487969', 'n_tokens_mistral': 1134, 'n_tokens_neox': 1113, 'n_words': 278}