<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('../lib')
from patXML import *

# Directory of test files
testdir = 'unittest/fixtures/'
xml_files = [x for x in os.listdir(testdir)
             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(testdir+xf).read())
    new = Patent(open(testdir+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()
        parser.setContentHandler(xmlhandler)
        parser.setFeature(handler.feature_external_ges, False)
        parser.parse(testdir+'basic.xml')
        self.assertTrue(xmlhandler.root)
        self.root = xmlhandler.root

    def test_basic_xml_tag_counts(self):
        self.assertTrue(len(self.root.a) == 1)
        self.assertTrue(len(self.root.a.b) == 2)
        self.assertTrue(len(self.root.a.b.c) == 3)<commit_msg>fix test directory paths<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('../lib')
from patXML import *

# Directory of test files
basedir = os.curdir
testdir = os.path.join(basedir, 'fixtures/unittest/fixtures/')
xml_files = [x for x in os.listdir(testdir)
             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(testdir+xf).read())
    new = Patent(open(testdir+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()
        parser.setContentHandler(xmlhandler)
        parser.setFeature(handler.feature_external_ges, False)
        parser.parse(testdir+'basic.xml')
        self.assertTrue(xmlhandler.root)
        self.root = xmlhandler.root

    def test_basic_xml_tag_counts(self):
        self.assertTrue(len(self.root.a) == 1)
        self.assertTrue(len(self.root.a.b) == 2)
        self.assertTrue(len(self.root.a.b.c) == 3)
{'fraction_non_alphanumeric': 0.11921063229963753, 'fraction_numerical': 0.005638340716874748, 'mean_word_length': 3.3886925795053005, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 32}, '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': '2064548', 'n_tokens_mistral': 845, 'n_tokens_neox': 837, 'n_words': 167}