Пример #1
0
def test_file_block_almost_same():
    # exactly same file
    f1 = """block1\n\nblock2"""
    f2 = """block1\n\nblock2"""
    assert (utils.file_block_almost_same(f1, f2))

    # same block, different sequence
    f1 = """block1\n\nblock2"""
    f2 = """block2\n\nblock1"""
    assert (utils.file_block_almost_same(f1, f2))

    # almost same block, same sequence
    f1 = """test data 9.5\n\nblock2"""
    f2 = """test data 9.500000000001\n\nblock2"""
    assert (utils.file_block_almost_same(f1, f2))

    # almost same block, different sequence
    f1 = """test data 9.5\n\nblock2"""
    f2 = """block2\n\ntest data 9.500000000001"""
    assert (utils.file_block_almost_same(f1, f2))

    # different block
    f1 = """block1\n\nblock2"""
    f2 = """block1\n\nblock3"""
    assert (utils.file_block_almost_same(f1, f2) == False)
Пример #2
0
def _activation_responses_test_step1(activation_responses_run_dir):
    os.chdir(thisdir)
    # copy ../scripts/activation_responses.py to activation_responses_run_dir/activation_responses.py
    os.chdir("..")
    folderpath = os.getcwd()
    dst = os.path.join(activation_responses_run_dir, "activation_responses.py")
    copyfile(os.path.join(folderpath, "scripts", "activation_responses.py"),
             dst)

    # run activation_responses step1
    os.chdir(activation_responses_run_dir)
    os.system('python activation_responses.py step1')

    # output files of activation_responses step1
    alara_inp = os.path.join(activation_responses_run_dir, "alara_inp")
    alara_matlib = os.path.join(activation_responses_run_dir, "alara_matlib")
    alara_fluxin = os.path.join(activation_responses_run_dir, "alara_fluxin")
    blank_mesh = os.path.join(activation_responses_run_dir, "blank_mesh.h5m")
    step1_file = os.path.join(activation_responses_run_dir,
                              "activation_responses_step1.h5m")

    exp_alara_inp = os.path.join(activation_responses_run_dir, "exp_alara_inp")
    exp_alara_matlib = os.path.join(activation_responses_run_dir,
                                    "exp_alara_matlib")
    exp_alara_fluxin = os.path.join(activation_responses_run_dir,
                                    "exp_alara_fluxin")

    # compare the output file of step1
    f1 = filecmp.cmp(alara_inp, exp_alara_inp)
    f2 = file_block_almost_same(alara_matlib, exp_alara_matlib)
    f3 = filecmp.cmp(alara_fluxin, exp_alara_fluxin)

    # remove test output files
    os.remove(alara_inp)
    os.remove(alara_fluxin)
    os.remove(alara_matlib)
    os.remove(blank_mesh)
    os.remove(step1_file)
    os.remove(dst)

    assert_equal(f1, True)
    assert_equal(f2, True)
    assert_equal(f3, True)
Пример #3
0
def _r2s_test_step1(r2s_run_dir, remove_step1_out=True):
    os.chdir(thisdir)
    # copy ../scripts/r2s.py to r2s_run_dir/r2s.py
    os.chdir("..")
    folderpath = os.getcwd()
    dst = os.path.join(r2s_run_dir, "r2s.py")
    copyfile(os.path.join(folderpath, "scripts", "r2s.py"), dst)

    # run r2s step1
    os.chdir(r2s_run_dir)
    os.system('python r2s.py step1')

    # output files of r2s step1
    alara_inp = os.path.join(r2s_run_dir, "alara_inp")
    alara_matlib = os.path.join(r2s_run_dir, "alara_matlib")
    alara_fluxin = os.path.join(r2s_run_dir, "alara_fluxin")
    blank_mesh = os.path.join(r2s_run_dir, "blank_mesh.h5m")
    step1_file = os.path.join(r2s_run_dir, "r2s_step1.h5m")

    exp_alara_inp = os.path.join(r2s_run_dir, "exp_alara_inp")
    exp_alara_matlib = os.path.join(r2s_run_dir, "exp_alara_matlib")
    exp_alara_fluxin = os.path.join(r2s_run_dir, "exp_alara_fluxin")

    # compare the output file of step1
    f1 = filecmp.cmp(alara_inp, exp_alara_inp)
    f2 = file_block_almost_same(alara_matlib, exp_alara_matlib)
    f3 = filecmp.cmp(alara_fluxin, exp_alara_fluxin)

    # remove test output files
    if remove_step1_out:
        # these files are used in step2
        os.remove(blank_mesh)
        os.remove(alara_inp)
    # these files are not used in step2
    os.remove(alara_fluxin)
    os.remove(alara_matlib)
    os.remove(step1_file)
    os.remove(dst)

    assert_equal(f1, True)
    assert_equal(f2, True)
    assert_equal(f3, True)