Exemplo n.º 1
0
def test_write_text():
    if 'leu.txt' in os.listdir('.'):
        os.remove('leu.txt')

    leu = Material({'U235': 0.04, 'U238': 0.96}, 42.0, 1.0, 1.0)
    leu.write_text('leu.txt')

    with open('leu.txt') as f:
        written = f.read()
    expected = ("Mass    42\n"
                "Density 1\n"
                "APerM   1\n"
                "U235    0.04\n"
                "U238    0.96\n")
    assert_equal(written, expected)

    read_leu = from_text('leu.txt')
    assert_equal(leu.mass, read_leu.mass)
    assert_equal(leu.atoms_per_molecule, read_leu.atoms_per_molecule)
    assert_equal(leu.comp, read_leu.comp)

    os.remove('leu.txt')
Exemplo n.º 2
0
def test_write_text():
    if 'leu.txt' in os.listdir('.'):
        os.remove('leu.txt')

    leu = Material({'U235': 0.04, 'U238': 0.96}, 42.0, 1.0, 1.0)
    leu.write_text('leu.txt')

    with open('leu.txt') as f:
        written = f.read()
    expected = ("Mass    42\n"
                "Density 1\n"
                "APerM   1\n"
                "U235    0.04\n"
                "U238    0.96\n")
    assert_equal(written, expected)

    read_leu = from_text('leu.txt')
    assert_equal(leu.mass, read_leu.mass)
    assert_equal(leu.atoms_per_mol, read_leu.atoms_per_mol)
    assert_equal(leu.comp, read_leu.comp)

    os.remove('leu.txt')
Exemplo n.º 3
0
def test_from_text_func():
    mat = from_text("mat.txt")
    assert_equal(mat.comp, {922350: 0.05, 922380: 0.95})
Exemplo n.º 4
0
def test_from_text_func():
    mat= from_text("mat.txt")
    assert_equal(mat.comp, {922350000: 0.05, 922380000: 0.95})