<commit_before>import pytest
from rhcephpkg import Hello
from rhcephpkg.tests.util import fake_urlopen, CallRecorder


class TestHelloJenkins(object):

    def test_main(self, monkeypatch):
        recorder = CallRecorder()
        monkeypatch.setattr(Hello, '_run', recorder)
        hello = Hello([])
        hello.main()
        assert recorder.called

    def test_help(self, monkeypatch, capsys):
        hello = Hello(['rhcephpkg', '--help'])
        with pytest.raises(SystemExit):
            hello.main()
        out, _ = capsys.readouterr()
        assert "Test authentication to Jenkins" in out

    def test_success(self, monkeypatch, capsys):
        # python-jenkins uses a "from" import, "from X import Y", so
        # monkeypatching is trickier.
        monkeypatch.setattr('jenkins.urlopen', fake_urlopen)
        # Another option would be to use func_code. This globally patches all
        # calls to urlopen(), not just jenkins' calls.
        # monkeypatch.setattr('six.moves.urllib.request.urlopen.func_code',
        #                     fake_urlopen.func_code)
        hello = Hello([])
        hello._run()<commit_msg>tests: drop test_hello.py unused monkeypatch fixture<commit_after>import pytest
from rhcephpkg import Hello
from rhcephpkg.tests.util import fake_urlopen, CallRecorder


class TestHelloJenkins(object):

    def test_main(self, monkeypatch):
        recorder = CallRecorder()
        monkeypatch.setattr(Hello, '_run', recorder)
        hello = Hello([])
        hello.main()
        assert recorder.called

    def test_help(self, capsys):
        hello = Hello(['rhcephpkg', '--help'])
        with pytest.raises(SystemExit):
            hello.main()
        out, _ = capsys.readouterr()
        assert "Test authentication to Jenkins" in out

    def test_success(self, monkeypatch, capsys):
        # python-jenkins uses a "from" import, "from X import Y", so
        # monkeypatching is trickier.
        monkeypatch.setattr('jenkins.urlopen', fake_urlopen)
        # Another option would be to use func_code. This globally patches all
        # calls to urlopen(), not just jenkins' calls.
        # monkeypatch.setattr('six.moves.urllib.request.urlopen.func_code',
        #                     fake_urlopen.func_code)
        hello = Hello([])
        hello._run()
{'fraction_non_alphanumeric': 0.09974093264248704, 'fraction_numerical': 0.0, 'mean_word_length': 2.643081761006289, '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': '900352', 'n_tokens_mistral': 721, 'n_tokens_neox': 668, 'n_words': 177}