Esempio n. 1
0
def test_user_can_set_an_array():
    reference = Molecule(atoms)
    reference.set_array("numbers", [1, 2, 3])
    numbers = reference.get_array("numbers")
    assert numbers[0] == 1
    assert numbers[1] == 2
    assert numbers[2] == 3
    reference.set_array("numbers", None)
    reference.set_array("numbers", None)
    with pytest.raises(Exception) as error:
        reference.get_array("numbers")
    assert error.value.args[0] == "numbers"
    reference.set_array("numbers", [1, 2, 3], None)
    numbers = reference.get_array("numbers")
    assert numbers[0] == 1
Esempio n. 2
0
def test_user_cannot_set_array_with_different_sizes():
    reference = Molecule(atoms)
    with pytest.raises(Exception) as error:
        reference.set_array("symbols", [1, 2, 3, 4])
    assert "4 != 3" in error.value.args[0]