<commit_before># -*- coding: utf-8 -*-

from __future__ import absolute_import

import os

import pytest
from tests.support.case import ShellCase, SPMCase
from tests.support.helpers import slowTest


@pytest.mark.windows_whitelisted
class SPMTest(ShellCase, SPMCase):
    """
    Test spm script
    """

    @slowTest
    def test_spm_help(self):
        """
        test --help argument for spm
        """
        expected_args = ["--version", "--assume-yes", "--help"]
        output = self.run_spm("--help")
        for arg in expected_args:
            self.assertIn(arg, "".join(output))

    @slowTest
    def test_spm_bad_arg(self):
        """
        test correct output when bad argument passed
        """
        expected_args = ["--version", "--assume-yes", "--help"]
        output = self.run_spm("doesnotexist")
        for arg in expected_args:
            self.assertIn(arg, "".join(output))

    @slowTest
    def test_spm_assume_yes(self):
        """
        test spm install with -y arg
        """
        config = self._spm_config(assume_yes=False)
        self._spm_build_files(config)

        spm_file = os.path.join(config["spm_build_dir"], "apache-201506-2.spm")

        build = self.run_spm("build {0} -c {1}".format(self.formula_dir, self._tmp_spm))

        install = self.run_spm("install {0} -c {1} -y".format(spm_file, self._tmp_spm))

        self.assertTrue(
            os.path.exists(os.path.join(config["formula_path"], "apache", "apache.sls"))
        )

    @slowTest
    def test_spm_force(self):
        """
        test spm install with -f arg
        """
        config = self._spm_config(assume_yes=False)
        self._spm_build_files(config)

        spm_file = os.path.join(config["spm_build_dir"], "apache-201506-2.spm")

        build = self.run_spm("build {0} -c {1}".format(self.formula_dir, self._tmp_spm))

        install = self.run_spm("install {0} -c {1} -y".format(spm_file, self._tmp_spm))

        self.assertTrue(
            os.path.exists(os.path.join(config["formula_path"], "apache", "apache.sls"))
        )

        # check if it forces the install after its already been installed it
        install = self.run_spm(
            "install {0} -c {1} -y -f".format(spm_file, self._tmp_spm)
        )

        self.assertEqual(["... installing apache"], install)<commit_msg>Drop Py2 and six on tests/integration/shell/test_spm.py<commit_after>import os

import pytest
from tests.support.case import ShellCase, SPMCase
from tests.support.helpers import slowTest


@pytest.mark.windows_whitelisted
class SPMTest(ShellCase, SPMCase):
    """
    Test spm script
    """

    @slowTest
    def test_spm_help(self):
        """
        test --help argument for spm
        """
        expected_args = ["--version", "--assume-yes", "--help"]
        output = self.run_spm("--help")
        for arg in expected_args:
            self.assertIn(arg, "".join(output))

    @slowTest
    def test_spm_bad_arg(self):
        """
        test correct output when bad argument passed
        """
        expected_args = ["--version", "--assume-yes", "--help"]
        output = self.run_spm("doesnotexist")
        for arg in expected_args:
            self.assertIn(arg, "".join(output))

    @slowTest
    def test_spm_assume_yes(self):
        """
        test spm install with -y arg
        """
        config = self._spm_config(assume_yes=False)
        self._spm_build_files(config)

        spm_file = os.path.join(config["spm_build_dir"], "apache-201506-2.spm")

        build = self.run_spm("build {} -c {}".format(self.formula_dir, self._tmp_spm))

        install = self.run_spm("install {} -c {} -y".format(spm_file, self._tmp_spm))

        self.assertTrue(
            os.path.exists(os.path.join(config["formula_path"], "apache", "apache.sls"))
        )

    @slowTest
    def test_spm_force(self):
        """
        test spm install with -f arg
        """
        config = self._spm_config(assume_yes=False)
        self._spm_build_files(config)

        spm_file = os.path.join(config["spm_build_dir"], "apache-201506-2.spm")

        build = self.run_spm("build {} -c {}".format(self.formula_dir, self._tmp_spm))

        install = self.run_spm("install {} -c {} -y".format(spm_file, self._tmp_spm))

        self.assertTrue(
            os.path.exists(os.path.join(config["formula_path"], "apache", "apache.sls"))
        )

        # check if it forces the install after its already been installed it
        install = self.run_spm("install {} -c {} -y -f".format(spm_file, self._tmp_spm))

        self.assertEqual(["... installing apache"], install)
{'fraction_non_alphanumeric': 0.14236336141715272, 'fraction_numerical': 0.008641175199827177, 'mean_word_length': 2.4245562130177514, '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': '6628517', 'n_tokens_mistral': 1579, 'n_tokens_neox': 1518, 'n_words': 304}