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

import os
import re
import sys
import unittest
from xml_driver import XMLElement, XMLHandler, Patent
from xml.sax import make_parser, handler

sys.path.append('..')
from patXML import *

# Directory of test files
xml_files = [x for x in os.listdir('test_xml_files')
             if re.match(r"2012_\d.xml", x) != None] # Match fixtures

parsed_xml_old = []
parsed_xml_new = []
for xf in xml_files:
    old = XMLPatentBase(open('test_xml_files/'+xf).read())
    parser = make_parser()
    new = XMLHandler()
    parser.setContentHandler(new)
    parser.setFeature(handler.feature_external_ges, False)
    parser.parse('test_xml_files/'+xf)

    parsed_xml_old.append(old)
    parsed_xml_new.append(new.root.us_patent_grant.us_bibliographic_data_grant)

class Test_XMLElement(unittest.TestCase):
    
    def setUp(self):
        # setup basic.xml parser/handler
        xmlhandler = XMLHandler()<commit_msg>use new Patent class in unit test<commit_after>#!/usr/bin/env python

import os
import re
import sys
import unittest
from xml_driver import XMLElement, XMLHandler, Patent
from xml.sax import make_parser, handler

sys.path.append('..')
from patXML import *

# Directory of test files
xml_files = [x for x in os.listdir('test_xml_files')
             if re.match(r"2012_\d.xml", x) != None] # Match fixtures

parsed_xml_old = []
parsed_xml_new = []
for xf in xml_files:
    old = XMLPatentBase(open('test_xml_files/'+xf).read())
    new = Patent(open('test_xml_files/'+xf))
    parsed_xml_old.append(old)
    parsed_xml_new.append(new)

class Test_XMLElement(unittest.TestCase):
    
    def setUp(self):
        # setup basic.xml parser/handler
        xmlhandler = XMLHandler()
        parser = make_parser()
{'fraction_non_alphanumeric': 0.11073059360730593, 'fraction_numerical': 0.0045662100456621, 'mean_word_length': 3.9380281690140846, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 28}, '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': '5435479', 'n_tokens_mistral': 601, 'n_tokens_neox': 589, 'n_words': 137}