Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pytest.raises() as exc_info has no .exception #2971

Closed
janosh opened this issue May 4, 2023 · 0 comments · Fixed by #2972
Closed

pytest.raises() as exc_info has no .exception #2971

janosh opened this issue May 4, 2023 · 0 comments · Fixed by #2972
Labels
bug tests Issues with or changes to the pymatgen test suite

Comments

@janosh
Copy link
Member

janosh commented May 4, 2023

We're misusing pytest.raises() in at least 4 places in 2 files. 2 Examples below where it should be

- str(context.exception)
+ str(context.value)

assert "Magmom type conflict" in str(context.exception)
# Test the behavior of MPRelaxSet to atomacically fill in the missing magmom
struct = self.structure.copy()
get_valid_magmom_struct(structure=struct, inplace=True, spin_mode="s")
struct.insert(0, "Li", [0, 0, 0])
vis = MPRelaxSet(struct, user_potcar_settings={"Fe": "Fe"}, validate_magmom=False)
with pytest.raises(TypeError) as context:
print(vis.get_vasp_input())
assert "argument must be a string" in str(context.exception)

@janosh janosh added bug tests Issues with or changes to the pymatgen test suite labels May 4, 2023
janosh added a commit that referenced this issue May 6, 2023
* fix AttributeError no .exception in pytest.raises() exc_info (closes #2971)

* pymatgen/io/vasp/tests/test_sets.py only skip tests that are actually failing PMG_VASP_PSP_DIR

* simplify: no need to convert list to array before passing to Lattice

* fix operator precedence in DictSet.kpoints

* refactor glob.glob imports

* issue warning in class DictSet if input structure contains Yb and input set uses Yb_2 PSP

* test all pre-PBE_54 input sets issue a Yb_2 warning
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug tests Issues with or changes to the pymatgen test suite
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant