<commit_before>#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Unit tests for PPP package."""

import unittest
from os import path as os_path
from pmix.odkform import OdkForm
from pmix.odkprompt import OdkPrompt
# from pmix.odkchoices import OdkChoices
from pmix.odkgroup import OdkGroup
# from pmix.odkrepeat import OdkRepeat
# from pmix.odktable import OdkTable

TEST_FORMS_DIRECTORY = os_path.dirname(os_path.realpath(__file__))


# pylint: disable=too-few-public-methods
# PyLint check not apply? - http://pylint-messages.wikidot.com/messages:r0903
class PppTest:
    """Base class for PPP package tests."""

    @staticmethod
    def get_forms(data):
        """Convert specified forms from form name strings to objects."""
        forms = {}
        for i in data:
            if i['file'] not in forms:
                forms[i['file']] = OdkForm(file=TEST_FORMS_DIRECTORY + '/' + i[
                    'file'])
        return forms


class OdkPromptTest(unittest.TestCase, PppTest):
    """Unit tests for the OdkPrompt class."""
    def setUp(self):
        self.data = (
            ({'file': 'FQ.xlsx',
              'media_types': ['image', 'audio', 'video', 'media::image',
                              'media::audio', 'media::video']},<commit_msg>Refactored tests to comply with PyLint, PyCodeStyle, PyDocStyle, and fixed a runtime error in one test.<commit_after>#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Unit tests for PPP package."""

import unittest
from os import path as os_path
from pmix.odkform import OdkForm
from pmix.odkprompt import OdkPrompt
# from pmix.odkchoices import OdkChoices
from pmix.odkgroup import OdkGroup
# from pmix.odkrepeat import OdkRepeat
# from pmix.odktable import OdkTable

TEST_FORMS_DIRECTORY = os_path.dirname(os_path.realpath(__file__))


# pylint: disable=too-few-public-methods
# PyLint check not apply? - http://pylint-messages.wikidot.com/messages:r0903
class PppTest:
    """Base class for PPP package tests."""

    @staticmethod
    def get_forms(data):
        """Convert specified forms from form name strings to objects."""
        forms = {}
        for datum in data:
            file = datum[0]['file']
            if file not in forms:
                forms[file] = OdkForm(file=TEST_FORMS_DIRECTORY + '/' + file)
        return forms


class OdkPromptTest(unittest.TestCase, PppTest):
    """Unit tests for the OdkPrompt class."""
    def setUp(self):
        self.data = (
            ({'file': 'FQ.xlsx',
              'media_types': ['image', 'audio', 'video', 'media::image',
                              'media::audio', 'media::video']},
{'fraction_non_alphanumeric': 0.12251908396946565, 'fraction_numerical': 0.004961832061068702, 'mean_word_length': 2.9177877428998507, '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': '5476654', 'n_tokens_mistral': 845, 'n_tokens_neox': 823, 'n_words': 229}