<commit_before>import unittest
from Numeric import *

from scipy_distutils.misc_util import add_grandparent_to_path,restore_path
from scipy_distutils.misc_util import add_local_to_path

add_grandparent_to_path(__name__)
import inline_tools
restore_path()

class test_inline(unittest.TestCase):
    """ These are long running tests...
    
         I'd like to benchmark these things somehow.
    """
    def check_exceptions(self):
        a = 1                                  
        code = """
               if (a < 2)
                   Py::ValueError("the variable 'a' should not be less than 2");
               return_val = Py::new_reference_to(Py::Int(a+1));
               """
        result = inline_tools.inline(code,['a'])
        assert(result == 2)
        
        try:
            a = 3
            result = inline_tools.inline(code,['a'])
            assert(1) # should've thrown a ValueError
        except ValueError:
            pass
        
        from distutils.errors import DistutilsError, CompileError    
        try:
            a = 'string'
            result = inline_tools.inline(code,['a'])
            assert(1) # should've gotten an error
        except: 
            # ?CompileError is the error reported, but catching it doesn't work<commit_msg>fixed a test that was broken.  The test also points out that exceptions can be skipped with when the C++ code isn't constructed correctly.<commit_after>import unittest
from Numeric import *

from scipy_distutils.misc_util import add_grandparent_to_path,restore_path
from scipy_distutils.misc_util import add_local_to_path

add_grandparent_to_path(__name__)
import inline_tools
restore_path()

class test_inline(unittest.TestCase):
    """ These are long running tests...
    
         I'd like to benchmark these things somehow.
    """
    def check_exceptions(self):
        a = 3                                  
        code = """
               if (a < 2)
                   Py::ValueError("the variable 'a' should not be less than 2");
               else    
                   return_val = Py::new_reference_to(Py::Int(a+1));
               """
        result = inline_tools.inline(code,['a'])
        assert(result == 4)
        
        try:
            a = 1
            result = inline_tools.inline(code,['a'])
            assert(1) # should've thrown a ValueError
        except ValueError:
            pass
        
        from distutils.errors import DistutilsError, CompileError    
        try:
            a = 'string'
            result = inline_tools.inline(code,['a'])
            assert(1) # should've gotten an error
        except: 
            # ?CompileError is the error reported, but catching it doesn't work
{'fraction_non_alphanumeric': 0.08483290488431877, 'fraction_numerical': 0.0058758721997796545, 'mean_word_length': 1.9321851453175458, 'pattern_counts': {'":': 0, '<': 5, '<?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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2209921', 'n_tokens_mistral': 753, 'n_tokens_neox': 721, 'n_words': 209}