<commit_before>from __future__ import print_function
import os
import sys
from argparse import Namespace

import nose
from nose.tools import assert_equal, assert_true, assert_false, assert_raises, \
    assert_in

cycdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
reldir = os.path.join(cycdir, 'release')
blddir = os.path.join(cycdir, 'build')
sys.path.insert(0, reldir)

import smbchk

def test_load():
    ns = Namespace(filename=os.path.join(reldir, 'symbols.json'))
    db = smbchk.load(ns)
    assert_true(isinstance(db, list))

def test_nm():
    if os.name != 'posix' or not os.path.isdir(blddir):
        return
    ns = Namespace(prefix=blddir)
    syms = smbchk.nm(ns)
    assert_in("cyclus::Agent::Agent(cyclus::Context*)", syms)

def test_diff():
    db = [{'symbols': ["cyclus::Agent::Agent(cyclus::Context*)"], 
           'version': 'X', 'date': 'x.x.x'}, 
          {'symbols': ["cyclus::Agent::Agent(cyclus::Context*)", 
                       "cyclus::Agent::~Agent()"], 
           'version': 'Y', 'date': 'y.y.y'},]
    obs = smbchk.diff(db, 0, 1)
    assert_true(len(obs) > 0)

def test_check():<commit_msg>fix for not finding tests<commit_after>from __future__ import print_function
import os
import sys
from argparse import Namespace

import nose
from nose.tools import assert_equal, assert_true, assert_false, assert_raises, \
    assert_in

cycdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
reldir = os.path.join(cycdir, 'release')
blddir = os.path.join(cycdir, 'build')
sys.path.insert(0, reldir)

try: 
    import smbchk
except ImportError:
    smbchk = False    

def test_load():
    if not smbchk:
        return
    ns = Namespace(filename=os.path.join(reldir, 'symbols.json'))
    db = smbchk.load(ns)
    assert_true(isinstance(db, list))

def test_nm():
    if not smbchk:
        return
    if os.name != 'posix' or not os.path.isdir(blddir):
        return
    ns = Namespace(prefix=blddir)
    syms = smbchk.nm(ns)
    assert_in("cyclus::Agent::Agent(cyclus::Context*)", syms)

def test_diff():
    if not smbchk:
        return
    db = [{'symbols': ["cyclus::Agent::Agent(cyclus::Context*)"], 
           'version': 'X', 'date': 'x.x.x'}, 
          {'symbols': ["cyclus::Agent::Agent(cyclus::Context*)", 
                       "cyclus::Agent::~Agent()"], 
           'version': 'Y', 'date': 'y.y.y'},]
    obs = smbchk.diff(db, 0, 1)
    assert_true(len(obs) > 0)

def test_check():
    if not smbchk:
        return
{'fraction_non_alphanumeric': 0.16152304609218437, 'fraction_numerical': 0.0032064128256513026, 'mean_word_length': 3.425531914893617, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '6499120', 'n_tokens_mistral': 921, 'n_tokens_neox': 922, 'n_words': 188}