<commit_before>from subprocess import Popen, PIPE

def test_init():
    #python2 tagm.py init'
    # Should result in a .tagm.db file being created
    out, err = test_cmd( [ 'tagm.py', 'init' ] )
    
    assert out == '''Initialized tagm database in .tagm.db'''
    assert err == ''

def test_cmd( cmd ):
    proc = Popen( cmd, stdout = PIPE, stderr = PIPE )
    
    stdout, stderr = proc.communicate()
    
    assert proc.returncode == 0
    
    return stdout, stderr

def run_test( test_func ):
    print 'Running %s...' % test_func.__name__,
    
    test_func()
    
    print 'Passed!'

def run_all_tests():
    run_test( test_init )

    #run_test( test_add_tags )
    
    #run_test( test_get_objs_by_tags )
    
    #run_test( test_get_tags_by_tags )
    <commit_msg>Changed base test setup to be contained in test-data folder<commit_after>from subprocess import Popen, PIPE
import os, shutil

def test_init():
    #python2 tagm.py init'
    # Should result in a .tagm.db file being created
    out, err = test_cmd( [ '../tagm.py', 'init' ] )
    
    assert out == 'Initiated tagm database in .tagm.db\n'
    assert err == ''

def test_cmd( cmd ):
    proc = Popen( cmd, stdout = PIPE, stderr = PIPE )
    
    stdout, stderr = proc.communicate()
    
    assert proc.returncode == 0
    
    return stdout, stderr

def run_test( test_func ):
    print 'Running %s...' % test_func.__name__,
    
    # create test-data folder
    os.mkdir( 'test-data' )
    os.chdir( 'test-data' )
    
    try:
        test_func()
    finally:
        # remove test-data folder along with any files in it.
        os.chdir( '..' )
        shutil.rmtree( 'test-data' )
    
    print 'Passed!'

def run_all_tests():
    run_test( test_init )

    #run_test( test_add_tags )
    
    #run_test( test_get_objs_by_tags )
    
    #run_test( test_get_tags_by_tags )
    
{'fraction_non_alphanumeric': 0.11373390557939914, 'fraction_numerical': 0.002145922746781116, 'mean_word_length': 2.4220183486238533, 'pattern_counts': {'":': 0, '<': 3, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '287673', 'n_tokens_mistral': 667, 'n_tokens_neox': 661, 'n_words': 175}