<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2010 <NAME>.
# See LICENSE for details.
#
# Time-stamp: <30-Dec-2010 13:34:19 PST by <EMAIL>>

"""
Tests for elffile.
"""

from __future__ import unicode_literals, print_function

__docformat__ = 'restructuredtext en'

import nose
from nose.tools import assert_true, assert_false, assert_equal, assert_raises, raises

### uncomment these for verbose logging
# import logging
# logger = logging.getLogger()
# handler = logging.StreamHandler()
# handler.setLevel(rcmp.INDETERMINATES)
# logger.addHandler(handler)

def test1():
    pass

if __name__ == '__main__':
    nose.main()<commit_msg>read and loop test ElfFileIdent.<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2010 <NAME>.
# See LICENSE for details.
#
# Time-stamp: <30-Dec-2010 21:01:30 PST by <EMAIL>>

"""
Tests for elffile.
"""

from __future__ import unicode_literals, print_function

__docformat__ = 'restructuredtext en'

import nose
from nose.tools import assert_true, assert_false, assert_equal, assert_raises, raises

import glob
import sys
import os

import elffile

def testElfFileIdent():
    for filename in glob.glob(os.path.join('..', 'elf32-examples', '*')) + glob.glob(os.path.join('..', 'elf64-examples', '*')):
        with open(filename, 'rb') as f:
            content = f.read()

        efi = elffile.ElfFileIdent()
        efi.unpack(content)
        print(efi, file=sys.stderr)
        newcontent = bytearray(elffile.EI_NIDENT)
        efi.pack(newcontent)

        # if content != newcontent:
        #     print('len(content) = {0}, len(newcontent) = {1}'.format(len(content), len(newcontent)))

        #     for i in xrange(len(content)):
        #         if content[i] != newcontent[i]:
        #             print('differs at char {0}: {1} != {2}'.format(i, content[i], newcontent[i]))

        content.startswith(newcontent)

        efi2 = elffile.ElfFileIdent()
        efi2.unpack(str(newcontent))
        assert_equal(efi, efi2)

if __name__ == '__main__':
    nose.main()
{'fraction_non_alphanumeric': 0.14444444444444443, 'fraction_numerical': 0.022705314009661835, 'mean_word_length': 3.4063829787234043, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '6448596', 'n_tokens_mistral': 742, 'n_tokens_neox': 698, 'n_words': 164}