<commit_before># /test/test_setuptools_green.py
#
# Tests for setuptools-green.
#
# See /LICENCE.md for Copyright information
"""Tests for setuptools-green."""

import sys

import green.cmdline

from mock import Mock

from setuptools import Distribution

from setuptools_green import GreenTestCommand

from testtools import TestCase
from testtools.matchers import (Contains, Not)


class TestGreenTestCommand(TestCase):

    """Test cases for the GreenTestCommand class."""

    def __init__(self, *args, **kwargs):
        """Initialize instance variables on this test case."""
        super(TestGreenTestCommand, self).__init__(*args, **kwargs)

    def setUp(self):
        """Patch out functions to monitor GreenTestCommand behaviour."""
        super(TestGreenTestCommand, self).setUp()

        self.patch(green.cmdline, "main", Mock(spec=green.cmdline.main))
        self.patch(sys, "exit", Mock(spec=green.cmdline.main))

    def test_run_quiet(self):
        """Run green tests quietly."""
        cmd = GreenTestCommand(Distribution())
        cmd.quiet = True
        cmd.ensure_finalized()
        cmd.run()
        self.assertThat(green.cmdline.sys.argv, Not(Contains("-vvv")))

    def test_run_verbose(self):
        """Run green tests verbosely."""
        GreenTestCommand(Distribution()).run()
        self.assertThat(green.cmdline.sys.argv, Contains("-vvv"))

    def test_use_exit_status(self):
        """Use Green's exit status."""
        green.cmdline.main.return_value = 1
        GreenTestCommand(Distribution()).run()
        sys.exit.assert_called_with(1)<commit_msg>Expect DistutilsArgError when passing invalid option.<commit_after># /test/test_setuptools_green.py
#
# Tests for setuptools-green.
#
# See /LICENCE.md for Copyright information
"""Tests for setuptools-green."""

import sys

from distutils.errors import DistutilsArgError

import green.cmdline

from mock import Mock

from setuptools import Distribution

from setuptools_green import GreenTestCommand

from testtools import ExpectedException, TestCase
from testtools.matchers import (Contains, Not)


class TestGreenTestCommand(TestCase):

    """Test cases for the GreenTestCommand class."""

    def __init__(self, *args, **kwargs):
        """Initialize instance variables on this test case."""
        super(TestGreenTestCommand, self).__init__(*args, **kwargs)

    def setUp(self):
        """Patch out functions to monitor GreenTestCommand behaviour."""
        super(TestGreenTestCommand, self).setUp()

        self.patch(green.cmdline, "main", Mock(spec=green.cmdline.main))
        self.patch(sys, "exit", Mock(spec=green.cmdline.main))

    def test_run_quiet(self):
        """Run green tests quietly."""
        cmd = GreenTestCommand(Distribution())
        cmd.quiet = True
        cmd.ensure_finalized()
        cmd.run()
        self.assertThat(green.cmdline.sys.argv, Not(Contains("-vvv")))

    def test_invalid_option(self):
        """Invalidly formed options throw."""
        with ExpectedException(DistutilsArgError):
            cmd = GreenTestCommand(Distribution())
            cmd.quiet = "A string"
            cmd.ensure_finalized()
            cmd.run()

    def test_run_verbose(self):
        """Run green tests verbosely."""
        GreenTestCommand(Distribution()).run()
        self.assertThat(green.cmdline.sys.argv, Contains("-vvv"))

    def test_use_exit_status(self):
        """Use Green's exit status."""
        green.cmdline.main.return_value = 1
        GreenTestCommand(Distribution()).run()
        sys.exit.assert_called_with(1)
{'fraction_non_alphanumeric': 0.11838790931989925, 'fraction_numerical': 0.001119507416736636, 'mean_word_length': 3.4123456790123456, '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': '5191136', 'n_tokens_mistral': 1027, 'n_tokens_neox': 1000, 'n_words': 244}