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

Title assert accepts strings #229

Merged
merged 17 commits into from
Apr 2, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
* Made `assert_string_contains()` accept a string instead of a list (@nkorinek, #53)
* Added functions to get and assert the midpoint values of bins in a histogram (@nkorinek, #184)
* Created tests for the autograde module (@nkorinek, #105)
* Created tests for the vector module (@nkorinek, #209)
Expand Down
4 changes: 4 additions & 0 deletions matplotcheck/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ def assert_string_contains(
return

string = string.lower().replace(" ", "")

if isinstance(strings_expected, str):
strings_expected = [strings_expected]

for check in strings_expected:
if isinstance(check, str):
if not check.lower().replace(" ", "") in string:
Expand Down
6 changes: 6 additions & 0 deletions matplotcheck/tests/test_base_titles_captions.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ def test_title_contains_axes_spaces(pt_line_plt):
plt.close()


def test_title_contains_axes_string(pt_line_plt):
"""Check title_contains for axes title as a string, not a list"""
pt_line_plt.assert_title_contains("My Plot Title", title_type="axes")
plt.close()


def test_title_contains_axes_badtext(pt_line_plt):
"""Check title_contains fails when given bad text"""
with pytest.raises(
Expand Down