<commit_before>#!/usr/bin/env python

import unittest

import pynuodb


class NuoDBBasicTest(unittest.TestCase):
    def test_toByteString(self):
        self.assertEqual(pynuodb.crypt.toSignedByteString(1), '01'.decode('hex'))
        self.assertEqual(pynuodb.crypt.toSignedByteString(127), '7F'.decode('hex'))
        self.assertEqual(pynuodb.crypt.toSignedByteString(254), '00FE'.decode('hex'))
        self.assertEqual(pynuodb.crypt.toSignedByteString(255), '00FF'.decode('hex'))
        self.assertEqual(pynuodb.crypt.toSignedByteString(-1), 'FF'.decode('hex'))
        self.assertEqual(pynuodb.crypt.toSignedByteString(-2), 'FE'.decode('hex'))
        self.assertEqual(pynuodb.crypt.toSignedByteString(-256), 'FF00'.decode('hex'))
        self.assertEqual(pynuodb.crypt.toSignedByteString(-258), 'FEFE'.decode('hex'))

    def test_fromByteString(self):
        self.assertEqual(pynuodb.crypt.fromSignedByteString('01'.decode('hex')), 1)
        self.assertEqual(pynuodb.crypt.fromSignedByteString('00FF'.decode('hex')), 255)
        self.assertEqual(pynuodb.crypt.fromSignedByteString('FF'.decode('hex')), -1)
        self.assertEqual(pynuodb.crypt.fromSignedByteString('FF01'.decode('hex')), -255)
        self.assertEqual(pynuodb.crypt.fromSignedByteString('FF00'.decode('hex')), -256)
        self.assertEqual(pynuodb.crypt.fromSignedByteString('FEFE'.decode('hex')), -258)

    def test_bothByteString(self):
        self.assertEqual(pynuodb.crypt.fromSignedByteString(pynuodb.crypt.toSignedByteString(1)), 1)
        self.assertEqual(pynuodb.crypt.fromSignedByteString(pynuodb.crypt.toSignedByteString(0)), 0)
        self.assertEqual(pynuodb.crypt.fromSignedByteString(pynuodb.crypt.toSignedByteString(-1)), -1)
        self.assertEqual(pynuodb.crypt.fromSignedByteString(pynuodb.crypt.toSignedByteString(256)), 256)
        self.assertEqual(pynuodb.crypt.fromSignedByteString(pynuodb.crypt.toSignedByteString(-256)), -256)


if __name__ == '__main__':
    unittest.main()<commit_msg>Updated crypt test values for python 2 and 3<commit_after>#!/usr/bin/env python

import unittest
import binascii
import pynuodb


class NuoDBBasicTest(unittest.TestCase):
    def test_toByteString(self):
        self.assertEqual(pynuodb.crypt.toSignedByteString(1), '\x01')
        self.assertEqual(pynuodb.crypt.toSignedByteString(127), '\x7f')
        self.assertEqual(pynuodb.crypt.toSignedByteString(254), '\x00\xfe')
        self.assertEqual(pynuodb.crypt.toSignedByteString(255), '\x00\xff')
        self.assertEqual(pynuodb.crypt.toSignedByteString(-1), '\xff')
        self.assertEqual(pynuodb.crypt.toSignedByteString(-2), '\xfe')
        self.assertEqual(pynuodb.crypt.toSignedByteString(-256), '\xff\x00')
        self.assertEqual(pynuodb.crypt.toSignedByteString(-258), '\xfe\xfe')

    def test_fromByteString(self):
        self.assertEqual(pynuodb.crypt.fromSignedByteString('\x01'), 1)
        self.assertEqual(pynuodb.crypt.fromSignedByteString('\x00\xff'), 255)
        self.assertEqual(pynuodb.crypt.fromSignedByteString('\xff'), -1)
        self.assertEqual(pynuodb.crypt.fromSignedByteString('\xff\x01'), -255)
        self.assertEqual(pynuodb.crypt.fromSignedByteString('\xff\x00'), -256)
        self.assertEqual(pynuodb.crypt.fromSignedByteString('\xfe\xfe'), -258)

    def test_bothByteString(self):
        self.assertEqual(pynuodb.crypt.fromSignedByteString(pynuodb.crypt.toSignedByteString(1)), 1)
        self.assertEqual(pynuodb.crypt.fromSignedByteString(pynuodb.crypt.toSignedByteString(0)), 0)
        self.assertEqual(pynuodb.crypt.fromSignedByteString(pynuodb.crypt.toSignedByteString(-1)), -1)
        self.assertEqual(pynuodb.crypt.fromSignedByteString(pynuodb.crypt.toSignedByteString(256)), 256)
        self.assertEqual(pynuodb.crypt.fromSignedByteString(pynuodb.crypt.toSignedByteString(-256)), -256)


if __name__ == '__main__':
    unittest.main()
{'fraction_non_alphanumeric': 0.1476337448559671, 'fraction_numerical': 0.03497942386831276, 'mean_word_length': 4.73598820058997, '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': '3276797', 'n_tokens_mistral': 1518, 'n_tokens_neox': 1340, 'n_words': 121}