<commit_before>import unittest
from tkp.testutil import db_subs, data
from ConfigParser import SafeConfigParser
from tkp.config import parse_to_dict
from tkp.testutil.data import default_job_config
from tkp.testutil import Mock
import tkp.steps.source_extraction
import tkp.accessors

class MockImage(Mock):
    def extract(self, *args, **kwargs):
        return self.__call__(*args, **kwargs)

class TestSourceExtraction(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        cls.dataset_id = db_subs.create_dataset_8images()
        config = SafeConfigParser()
        config.read(default_job_config)
        config = parse_to_dict(config)
        cls.parset = config['source_extraction']

    def test_extract_sources(self):
        image_path = data.fits_file
        tkp.steps.source_extraction.extract_sources(image_path, self.parset)
<commit_msg>Fix the mock-image used in test-steps unittests.<commit_after>import unittest
import numpy as np
from tkp.testutil import db_subs, data
from ConfigParser import SafeConfigParser
from tkp.config import parse_to_dict
from tkp.testutil.data import default_job_config
from tkp.testutil import Mock
import tkp.steps.source_extraction
import tkp.accessors


class MockImage(Mock):
    def extract(self, *args, **kwargs):
        return self.__call__(*args, **kwargs)
    @property
    def rmsmap(self, *args, **kwargs):
        return np.zeros((1))


class TestSourceExtraction(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        cls.dataset_id = db_subs.create_dataset_8images()
        config = SafeConfigParser()
        config.read(default_job_config)
        config = parse_to_dict(config)
        cls.parset = config['source_extraction']

    def test_extract_sources(self):
        image_path = data.fits_file
        tkp.steps.source_extraction.extract_sources(image_path, self.parset)

{'fraction_non_alphanumeric': 0.08377801494130203, 'fraction_numerical': 0.0016008537886872999, 'mean_word_length': 4.122950819672131, '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': '4031312', 'n_tokens_mistral': 593, 'n_tokens_neox': 570, 'n_words': 129}