<commit_before>import unittest

from satella.coding.concurrent import call_in_separate_thread
from satella.opentracing import trace_exception, trace_future, trace_function
from unittest import mock


class TestOpentracing(unittest.TestCase):
    def test_trace_function(self):
        class MockTracer:
            def __init__(self):
                self.start_active_span_called = True

            def start_active_span(self, *args, **kwargs):
                class MockScope(mock.MagicMock):
                    def __enter__(self):
                        return self

                    def __exit__(self, exc_type, exc_val, exc_tb):
                        return False
                self.start_active_span_called = True
                return MockScope()

        tracer = MockTracer()

        @trace_function(tracer, 'trace_me')
        def trace_me():
            pass

        trace_me()
        self.assertTrue(tracer.start_active_span_called)

    def test_trace_future_success(self):
        @call_in_separate_thread()
        def test_me():
            pass

        fut = test_me()
        span = mock.MagicMock()
        trace_future(fut, span)
        fut.result()
        fut.thread.join()
        self.assertTrue(span.finish.called)
<commit_msg>refactor tests<commit_after>import unittest

from satella.coding.concurrent import call_in_separate_thread
from satella.opentracing import trace_exception, trace_future, trace_function
from unittest import mock


class TestOpentracing(unittest.TestCase):
    def test_trace_function(self):

        tracer = mock.Mock()

        @trace_function(tracer, 'trace_me')
        def trace_me():
            pass

        trace_me()
        self.assertTrue(tracer.start_active_span.called)

    def test_trace_future_success(self):
        @call_in_separate_thread()
        def test_me():
            pass

        fut = test_me()
        span = mock.MagicMock()
        trace_future(fut, span)
        fut.result()
        fut.thread.join()
        self.assertTrue(span.finish.called)

{'fraction_non_alphanumeric': 0.07857491459248414, 'fraction_numerical': 0.0, 'mean_word_length': 2.253968253968254, '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': '5364190', 'n_tokens_mistral': 593, 'n_tokens_neox': 579, 'n_words': 116}