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

import unittest
from random import Random
from binary_search_tree import BinarySearchTree
from tree_node import TreeNode


class TestBinarySearchTree(unittest.TestCase):

    def setUp(self):

        #tree 1
        self.tree = BinarySearchTree()
        random = Random(283)
        self.data = set([random.randint(1,1000) for i in xrange(100)])
        for v in self.data:
            self.tree.insert(v)

        #tree 2
        self.tree2 = BinarySearchTree()
        self.tree2.insert(20)
        self.tree2.insert(45)
        self.tree2.insert(12)

    def test_key_attributes(self):
        root = self.tree2._root
        node_12 = root.left
        node_45 = root.right
        self.assertIsInstance(root, TreeNode)
        self.assertEqual(root.left.key, 12)
        self.assertEqual(root.right.key, 45)
        self.assertEqual(root.parent, None)


        self.assertEqual(node_12.left, None)
        self.assertEqual(node_12.right, None)
        self.assertEqual(node_12.parent.key, 20)

        self.assertEqual(node_45.left, None)
        self.assertEqual(node_45.right, None)
        self.assertEqual(node_45.parent.key, 20)

    def test_insert(self):
        pass

    def tearDown(self):
        self.tree = None
        self.tree2 = None

if __name__ == '__main__':
    unittest.main()
<commit_msg>add Binary Search Tree testing<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-

import unittest
from random import Random
from binary_search_tree import BinarySearchTree
from tree_node import TreeNode


class TestBinarySearchTree(unittest.TestCase):

    def setUp(self):

        #tree 1
        self.tree = BinarySearchTree()
        random = Random(283)
        self.data = set([random.randint(1,1000) for i in xrange(100)])
        for v in self.data:
            self.tree.insert(v)

        #tree 2
        self.tree2 = BinarySearchTree()
        self.tree2.insert(20)
        self.tree2.insert(45)
        self.tree2.insert(12)

    def test_key_attributes(self):
        root = self.tree2._root
        node_12 = root.left
        node_45 = root.right
        self.assertIsInstance(root, TreeNode)
        self.assertEqual(root.left.key, 12)
        self.assertEqual(root.right.key, 45)
        self.assertEqual(root.parent, None)


        self.assertEqual(node_12.left, None)
        self.assertEqual(node_12.right, None)
        self.assertEqual(node_12.parent.key, 20)

        self.assertEqual(node_45.left, None)
        self.assertEqual(node_45.right, None)
        self.assertEqual(node_45.parent.key, 20)

    def test_insert(self):
        self.tree2.insert(15)
        node_15 = self.tree2._root.left.right
        self.assertEqual(node_15.left, None)
        self.assertEqual(node_15.right, None)
        self.assertEqual(node_15.parent.key, 12)
        pass

    def tearDown(self):
        self.tree = None
        self.tree2 = None

if __name__ == '__main__':
    unittest.main()

{'fraction_non_alphanumeric': 0.10717863105175292, 'fraction_numerical': 0.03806343906510851, 'mean_word_length': 2.4123006833712983, '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': '970523', 'n_tokens_mistral': 1022, 'n_tokens_neox': 929, 'n_words': 187}