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

Swap xfail for pytest.raises #50

Merged
merged 3 commits into from
Jun 3, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions tests/test_deltaRCM_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def test_init():

def test_update():
delta = pyDeltaRCM(input_file=os.path.join(os.getcwd(), 'tests', 'test.yaml'))

delta.update()
assert delta._time == 1.0
assert delta._is_finalized == False
Expand All @@ -33,7 +34,6 @@ def test_finalize():
assert delta._is_finalized == True


@pytest.mark.xfail(raises=RuntimeError, strict=True)
def test_multifinalization_error():
err_delta = pyDeltaRCM(input_file=os.path.join(os.getcwd(), 'tests', 'test.yaml'))
err_delta.update()
Expand All @@ -42,8 +42,9 @@ def test_multifinalization_error():
assert err_delta._is_finalized == False
err_delta.finalize()
assert err_delta._is_finalized == True
# next line should throw RuntimeError and test will xFail
err_delta.update()
# next line should throw RuntimeError
with pytest.raises(RuntimeError):
err_delta.update()


def test_getters_setters():
Expand Down
12 changes: 6 additions & 6 deletions tests/test_yaml_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ def test_override_from_testfile():
assert delta.Length == 10


@pytest.mark.xfail(raises=FileNotFoundError, strict=True)
def test_error_if_no_file_found():
delta = pyDeltaRCM(input_file='./nonexisting_file.yaml')
with pytest.raises(FileNotFoundError):
delta = pyDeltaRCM(input_file='./nonexisting_file.yaml')


def test_override_single_default(tmp_path):
Expand All @@ -60,22 +60,22 @@ def test_override_two_defaults(tmp_path):
assert delta.Np_sed == 2


@pytest.mark.xfail(raises=TypeError, strict=True)
def test_override_bad_type_float_string(tmp_path):
file_name = 'user_parameters.yaml'
p, f = create_temporary_file(tmp_path, file_name)
write_parameter_to_file(f, 'S0', 'a string?!')
f.close()
delta = pyDeltaRCM(input_file=p)
with pytest.raises(TypeError):
delta = pyDeltaRCM(input_file=p)


@pytest.mark.xfail(raises=TypeError, strict=True)
def test_override_bad_type_int_float(tmp_path):
file_name = 'user_parameters.yaml'
p, f = create_temporary_file(tmp_path, file_name)
write_parameter_to_file(f, 'beta', 24.4234)
f.close()
delta = pyDeltaRCM(input_file=p)
with pytest.raises(TypeError):
delta = pyDeltaRCM(input_file=p)


def test_not_creating_illegal_attributes(tmp_path):
Expand Down