<commit_before>﻿import unittest

import Tkinter
from Tests.MockObject import MockObject

Tkinter.__dict__['Tk'] = MockObject
Tkinter.__dict__['Label'] = MockObject
Tkinter.__dict__['Button'] = MockObject

import Handlers
import UI.GUI
import UI.Web
import inspect

class testHandler(object):
    def test_SetTextWithTestValueShouldSetTestValue(self):
        self.interface.SetText("TestValue")
        self.result_SetTextWithTestValueShouldSetTestValue()

    def result_SetTextWithTestValueShouldSetTestValue(self):
        self.throw_NotImplementedError()

    def throw_NotImplementedError(self):
        raise AssertionError("'%s.%s' does not implement result for '%s'" % (type(self.interface).__module__, type(self.interface).__name__, inspect.stack()[2][3][5:]))


class testGUIHandler(unittest.TestCase, testHandler):
    def setUp(self):
        self.interface = UI.GUI.index.Index()

    def test_ShouldListenToSubmitHandlerWhenSubmitCalled(self):
        self.assertEqual(1, len(self.interface.root.title.__receivedcalls__))
        self.assertTrue(self.interface.root.title.__ReceivedCall__("Multi-Interface Tool"))
        self.assertEqual(2, len(self.interface.root.children))
        self.interface.Render()

    def result_SetTextWithTestValueShouldSetTestValue(self):
        self.interface.label.config(text="TestValue")

class testWebHandler(unittest.TestCase, testHandler):
    def setUp(self):
        self.interface = UI.Web.index.Index((), {})

    def result_SetTextWithTestValueShouldSetTestValue(self):
        self.assertEqual("TestValue", self.interface.value)<commit_msg>Use TestCase.fail instead of AssertionError as per unittest doc.<commit_after>﻿import unittest

import Tkinter
from Tests.MockObject import MockObject

Tkinter.__dict__['Tk'] = MockObject
Tkinter.__dict__['Label'] = MockObject
Tkinter.__dict__['Button'] = MockObject

import Handlers
import UI.GUI
import UI.Web
import inspect

class testHandler(object):
    def test_SetTextWithTestValueShouldSetTestValue(self):
        self.interface.SetText("TestValue")
        self.result_SetTextWithTestValueShouldSetTestValue()

    def result_SetTextWithTestValueShouldSetTestValue(self):
        self.throw_NotImplementedError()

    def throw_NotImplementedError(self):
        unittest.TestCase.fail(self, "'%s.%s' does not implement result for '%s'" % (type(self.interface).__module__, type(self.interface).__name__, inspect.stack()[2][3][5:]))


class testGUIHandler(unittest.TestCase, testHandler):
    def setUp(self):
        self.interface = UI.GUI.index.Index()

    def test_ShouldListenToSubmitHandlerWhenSubmitCalled(self):
        self.assertEqual(1, len(self.interface.root.title.__receivedcalls__))
        self.assertTrue(self.interface.root.title.__ReceivedCall__("Multi-Interface Tool"))
        self.assertEqual(2, len(self.interface.root.children))
        self.interface.Render()

    def result_SetTextWithTestValueShouldSetTestValue(self):
        self.interface.label.config(text="TestValue")

class testWebHandler(unittest.TestCase, testHandler):
    def setUp(self):
        self.interface = UI.Web.index.Index((), {})

    def result_SetTextWithTestValueShouldSetTestValue(self):
        self.assertEqual("TestValue", self.interface.value)
{'fraction_non_alphanumeric': 0.11138386007977907, 'fraction_numerical': 0.003068425897514575, 'mean_word_length': 4.916515426497278, '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': '5245447', 'n_tokens_mistral': 951, 'n_tokens_neox': 941, 'n_words': 155}