<commit_before>

import unittest
from roles import RoleType, clone


class SimpleRole(object):
    __metaclass__ = RoleType
    __slots__ = ()

    def inrole(self):
        return "in role"


class TypesTest(unittest.TestCase):
    """
    Test application of roles on types.
    """

    def test_class(self):
        class Cls(object):
            pass

        c = Cls()
        SimpleRole(c)
        c.inrole()

    def test_class_with_args(self):
        class Cls(object):
            def __init__(self, a, b):
                pass

        c = Cls(1, 2)
        SimpleRole(c)
        c.inrole()

    def test_class_with_slots(self):
        class Cls(object):
            __slots__ = ('a', 'b')

            def __init__(self):
                pass

        c = Cls()
        SimpleRole(c)
        c.inrole()

    def test_dict(self):
        d = dict()
        try:
            SimpleRole(d)
        except TypeError, e:
            self.assertEquals("__class__ assignment: only for heap types", str(e))
        else:
            assert False, "should not be reached"

    def test_dict_subclass(self):
        class Dict(dict):
            pass
        d = Dict()
        d['a'] = 3
        SimpleRole(d)
        self.assertEquals('Dict+SimpleRole', d.__class__.__name__)
        self.assertEquals(3, d['a'])
        d.inrole()

    def test_list(self):
        d = ['a', 'b']
        try:
            SimpleRole(d)<commit_msg>Acknowledged issue with slots. No fix.<commit_after>

import unittest
from roles import RoleType, clone


class SimpleRole(object):
    __metaclass__ = RoleType
    __slots__ = ()

    def inrole(self):
        return "in role"


class TypesTest(unittest.TestCase):
    """
    Test application of roles on types.
    """

    def test_class(self):
        class Cls(object):
            pass

        c = Cls()
        SimpleRole(c)
        c.inrole()

    def test_class_with_args(self):
        class Cls(object):
            def __init__(self, a, b):
                pass

        c = Cls(1, 2)
        SimpleRole(c)
        c.inrole()

    def test_class_with_slots(self):
        class Cls(object):
            __slots__ = ('a', 'b')

            def __init__(self):
                pass

        c = Cls()
        try:
            SimpleRole(c)
        except TypeError, e:
            self.assertEquals("__class__ assignment: 'Cls' object layout differs from 'Cls+SimpleRole'", str(e))
        else:
            assert False, "should not be reached"

    def test_dict(self):
        d = dict()
        try:
            SimpleRole(d)
        except TypeError, e:
            self.assertEquals("__class__ assignment: only for heap types", str(e))
        else:
            assert False, "should not be reached"

    def test_dict_subclass(self):
        class Dict(dict):
            pass
        d = Dict()
        d['a'] = 3
        SimpleRole(d)
        self.assertEquals('Dict+SimpleRole', d.__class__.__name__)
        self.assertEquals(3, d['a'])
        d.inrole()

    def test_list(self):
        d = ['a', 'b']
        try:
            SimpleRole(d)
{'fraction_non_alphanumeric': 0.10957138253303254, 'fraction_numerical': 0.002578150177247825, 'mean_word_length': 1.682800345721694, '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': '465945', 'n_tokens_mistral': 971, 'n_tokens_neox': 933, 'n_words': 239}