<commit_before>from __future__ import absolute_import
from nesteddict import leaf_values, NestedDict
import pytest


class TestLeafValues:
    def test_shallow(self):
        d = {'a': 1, 'b': 'hello', 'c': (3, 2, 1), (1, 2, 3): 9}
        assert(set(leaf_values(d)) == set([1, 'hello', (3, 2, 1), 9]))

        d = NestedDict({'a': 1, 'b': 'hello', 'c': (3, 2, 1), (1, 2, 3): 9})
        assert(set(leaf_values(d)) == set([1, 'hello', (3, 2, 1), 9]))

        d = NestedDict()
        d[1] = 4
        d[2] = (3, 2, 1)
        d[4] = 'hello'
        assert(set(leaf_values(d)) == set([4, (3, 2, 1), 'hello']))

    def test_nested(self):
        d = {1: {2: {3: {4: 5, 5: 'hello'}}}, 2: {(3, 2, 1): (1, 2, 3), 4: 16}}
        assert(set(leaf_values(d)) == set([5, 'hello', (1, 2, 3), 16]))

        assert(set(leaf_values(NestedDict(d))) == {5, 'hello', (1, 2, 3), 16})

        d = NestedDict()
        d[1, 2, 3, 4] = 5
        d[1, 2, 3, 5] = 'hello'
        d[2, (3, 2, 1)] = (1, 2, 3)
        d[2, 4] = 16
        assert (set(leaf_values(d)) == set([5, 'hello', (1, 2, 3), 16]))

    def test_raises(self):
        with pytest.raises(TypeError, message="Expecting TypeError"):
            i = leaf_values(123)<commit_msg>Missed a set literal<commit_after>from __future__ import absolute_import
from nesteddict import leaf_values, NestedDict
import pytest


class TestLeafValues:
    def test_shallow(self):
        d = {'a': 1, 'b': 'hello', 'c': (3, 2, 1), (1, 2, 3): 9}
        assert(set(leaf_values(d)) == set([1, 'hello', (3, 2, 1), 9]))

        d = NestedDict({'a': 1, 'b': 'hello', 'c': (3, 2, 1), (1, 2, 3): 9})
        assert(set(leaf_values(d)) == set([1, 'hello', (3, 2, 1), 9]))

        d = NestedDict()
        d[1] = 4
        d[2] = (3, 2, 1)
        d[4] = 'hello'
        assert(set(leaf_values(d)) == set([4, (3, 2, 1), 'hello']))

    def test_nested(self):
        d = {1: {2: {3: {4: 5, 5: 'hello'}}}, 2: {(3, 2, 1): (1, 2, 3), 4: 16}}
        assert(set(leaf_values(d)) == set([5, 'hello', (1, 2, 3), 16]))

        assert(set(leaf_values(NestedDict(d))) == set([5, 'hello', (1, 2, 3), 16]))

        d = NestedDict()
        d[1, 2, 3, 4] = 5
        d[1, 2, 3, 5] = 'hello'
        d[2, (3, 2, 1)] = (1, 2, 3)
        d[2, 4] = 16
        assert (set(leaf_values(d)) == set([5, 'hello', (1, 2, 3), 16]))

    def test_raises(self):
        with pytest.raises(TypeError, message="Expecting TypeError"):
            i = leaf_values(123)
{'fraction_non_alphanumeric': 0.23357664233576642, 'fraction_numerical': 0.07623682076236821, 'mean_word_length': 2.5547550432276656, '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': '2852540', 'n_tokens_mistral': 1142, 'n_tokens_neox': 1006, 'n_words': 286}