<commit_before>from io import BytesIO
import pickle
import unittest
import warnings

from mock import Mock

from Orange.data import ContinuousVariable, DiscreteVariable, Domain
from Orange.widgets.settings import DomainContextHandler, ContextSetting, Setting, SettingsHandler, SettingProvider


CONTINOUS_ATTR = "cf1"
DISCRETE_ATTR_ABC = "df1"
DISCRETE_ATTR_DEF = "df2"
DISCRETE_CLASS_GHI = "dc1"
CONTINUOUS_META = "cm1"
DISCRETE_META_JKL = "dm1"

UNKNOWN_TYPE = -2
VALUE = "abc"

VarTypes = ContinuousVariable.VarTypes

domain = Domain(
    attributes=[
        ContinuousVariable(name=CONTINOUS_ATTR),
        DiscreteVariable(name=DISCRETE_ATTR_ABC, values=["a", "b", "c"]),
        DiscreteVariable(name=DISCRETE_ATTR_DEF, values=["d", "e", "f"])
    ],
    class_vars=[
        DiscreteVariable(name=DISCRETE_CLASS_GHI, values=["g", "h", "i"])
    ],
    metas=[
        ContinuousVariable(name=CONTINUOUS_META),
        DiscreteVariable(name=DISCRETE_META_JKL, values=["j", "k", "l"]),
    ]
)


class DomainEncodingTests(unittest.TestCase):
    def setUp(self):
        self.handler = DomainContextHandler(attributes_in_res=True,
                                            metas_in_res=True)

    def test_encode_domain_with_match_none(self):
        handler = DomainContextHandler(
            match_values=DomainContextHandler.MATCH_VALUES_NONE,
            metas_in_res=True)
<commit_msg>Tricked test_settings to work without VarTypes.<commit_after>from io import BytesIO
import pickle
import unittest
import warnings

from mock import Mock

from Orange.data import ContinuousVariable, DiscreteVariable, Domain
from Orange.widgets.settings import DomainContextHandler, ContextSetting, Setting, SettingsHandler, SettingProvider
from Orange.widgets.utils import vartype


CONTINOUS_ATTR = "cf1"
DISCRETE_ATTR_ABC = "df1"
DISCRETE_ATTR_DEF = "df2"
DISCRETE_CLASS_GHI = "dc1"
CONTINUOUS_META = "cm1"
DISCRETE_META_JKL = "dm1"

UNKNOWN_TYPE = -2
VALUE = "abc"

VarTypes = lambda: None
VarTypes.Continuous = vartype(ContinuousVariable())
VarTypes.Discrete = vartype(DiscreteVariable())

domain = Domain(
    attributes=[
        ContinuousVariable(name=CONTINOUS_ATTR),
        DiscreteVariable(name=DISCRETE_ATTR_ABC, values=["a", "b", "c"]),
        DiscreteVariable(name=DISCRETE_ATTR_DEF, values=["d", "e", "f"])
    ],
    class_vars=[
        DiscreteVariable(name=DISCRETE_CLASS_GHI, values=["g", "h", "i"])
    ],
    metas=[
        ContinuousVariable(name=CONTINUOUS_META),
        DiscreteVariable(name=DISCRETE_META_JKL, values=["j", "k", "l"]),
    ]
)


class DomainEncodingTests(unittest.TestCase):
    def setUp(self):
        self.handler = DomainContextHandler(attributes_in_res=True,
                                            metas_in_res=True)

    def test_encode_domain_with_match_none(self):
        handler = DomainContextHandler(
            match_values=DomainContextHandler.MATCH_VALUES_NONE,
            metas_in_res=True)

{'fraction_non_alphanumeric': 0.10311020960108182, 'fraction_numerical': 0.004732927653820149, 'mean_word_length': 4.0929432013769365, '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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5883799', 'n_tokens_mistral': 989, 'n_tokens_neox': 965, 'n_words': 178}