<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-

import unittest
from yalix.environment import Env


class TestAtom():

    def __init__(self, value):
        self.value = value

    def eval(self, env):
        return self.value


class GlobalFrameTests(unittest.TestCase):

    def test_define(self):
        env = Env()
        env['a'] = TestAtom('b')
        self.assertEqual('b', env['a'])

    def test_lookup_fails(self):
        env = Env()
        with self.assertRaises(KeyError):
            self.assertEqual('b', env['a'])

    def test_overwrite(self):
        env = Env()
        env['a'] = TestAtom('b')
        env['a'] = TestAtom('c')
        self.assertEqual('c', env['a'])

    def test_items(self):
        env = Env()
        self.assertListEqual(list(env.items()), [])
        for i in range(10):
            env[i] = TestAtom(i)
        self.assertEqual(range(10), sorted([k for k, _ in env.items()]))
        self.assertEqual(range(10), sorted([v for _, v in env.items()]))


class LocalStackTests(unittest.TestCase):
    pass


if __name__ == '__main__':
    unittest.main()<commit_msg>Tests compatible with Python3<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-

import unittest
from yalix.environment import Env


class TestAtom():

    def __init__(self, value):
        self.value = value

    def eval(self, env):
        return self.value


class GlobalFrameTests(unittest.TestCase):

    def test_define(self):
        env = Env()
        env['a'] = TestAtom('b')
        self.assertEqual('b', env['a'])

    def test_lookup_fails(self):
        env = Env()
        with self.assertRaises(KeyError):
            self.assertEqual('b', env['a'])

    def test_overwrite(self):
        env = Env()
        env['a'] = TestAtom('b')
        env['a'] = TestAtom('c')
        self.assertEqual('c', env['a'])

    def test_items(self):
        env = Env()
        self.assertListEqual(list(env.items()), [])
        for i in range(10):
            env[i] = TestAtom(i)
        self.assertEqual(list(range(10)), sorted([k for k, _ in env.items()]))
        self.assertEqual(list(range(10)), sorted([v for _, v in env.items()]))


class LocalStackTests(unittest.TestCase):
    pass


if __name__ == '__main__':
    unittest.main()
{'fraction_non_alphanumeric': 0.15978928884986832, 'fraction_numerical': 0.006584723441615452, 'mean_word_length': 2.5609375, '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': '6259366', 'n_tokens_mistral': 753, 'n_tokens_neox': 724, 'n_words': 162}