<commit_before>from mock import call, patch
import pytest
from merfi.backends import gpg
from merfi.tests.backends.base import BaseBackendTest

class TestGpg(BaseBackendTest):

    backend = gpg.Gpg([])

    # args to merfi.backends.gpg.util's run()
    detached = ['gpg', '--batch', '--yes', '--armor', '--detach-sig', '--output', 'Release.gpg', 'Release']
    clearsign = ['gpg', '--batch', '--yes', '--clearsign', '--output', 'InRelease', 'Release']

    @patch("merfi.backends.gpg.util")
    def test_sign_no_files(self, m_util, tmpdir):
        super(TestGpg, self).test_sign_no_files(m_util, tmpdir)
        assert not m_util.run.called

    @patch("merfi.backends.gpg.util")
    def test_sign_two_files(self, m_util, repotree):
        super(TestGpg, self).test_sign_two_files(m_util, repotree)
        # Our repotree fixture has two "Release" files.
        # Each one gets detached-signed and clearsign'd.
        calls = [
            call(self.detached),
            call(self.clearsign),
            call(self.detached),
            call(self.clearsign),
        ]
        m_util.run.assert_has_calls(calls)
<commit_msg>GpgTest: rm references to BaseBackendTest<commit_after>from mock import call, patch
import pytest
from merfi.backends import gpg

class TestGpg(object):

    backend = gpg.Gpg([])

    # args to merfi.backends.gpg.util's run()
    detached = ['gpg', '--batch', '--yes', '--armor', '--detach-sig', '--output', 'Release.gpg', 'Release']
    clearsign = ['gpg', '--batch', '--yes', '--clearsign', '--output', 'InRelease', 'Release']

    @patch("merfi.backends.gpg.util")
    def test_sign_no_files(self, m_util, tmpdir):
        self.backend.path = str(tmpdir)
        self.backend.sign()
        assert not m_util.run.called

    @patch("merfi.backends.gpg.util")
    def test_sign_two_files(self, m_util, repotree):
        self.backend.path = repotree
        self.backend.sign()
        # Our repotree fixture has two "Release" files.
        # Each one gets detached-signed and clearsign'd.
        calls = [
            call(self.detached),
            call(self.clearsign),
            call(self.detached),
            call(self.clearsign),
        ]
        m_util.run.assert_has_calls(calls)

{'fraction_non_alphanumeric': 0.14881219184222322, 'fraction_numerical': 0.0, 'mean_word_length': 2.795918367346939, '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': '6697219', 'n_tokens_mistral': 772, 'n_tokens_neox': 768, 'n_words': 156}