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

Fix empty string bug on dataframe regression #74

Merged
merged 3 commits into from
Sep 15, 2021
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.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
------------------

* `#54 <https://github.com/ESSS/pytest-regressions/pull/54>`__: New ``--with-test-class-names`` command-line flag to consider test class names when composing the expected and obtained data filenames. Needed when the same module contains different classes with the same method names.
* `#74 <https://github.com/ESSS/pytest-regressions/pull/74>`__: Fix ``empty string bug`` on dataframe regression.

2.2.0 (2020-01-27)
------------------
Expand Down
4 changes: 2 additions & 2 deletions src/pytest_regressions/dataframe_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ def _check_fn(self, obtained_filename, expected_filename):

__tracebackhide__ = True

obtained_data = pd.read_csv(str(obtained_filename))
expected_data = pd.read_csv(str(expected_filename))
obtained_data = pd.read_csv(str(obtained_filename), keep_default_na=False)
expected_data = pd.read_csv(str(expected_filename), keep_default_na=False)

comparison_tables_dict = {}
for k in obtained_data.keys():
Expand Down
11 changes: 11 additions & 0 deletions tests/test_dataframe_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,3 +252,14 @@ def test_non_pandas_dataframe(dataframe_regression):
" *Object with type '%s' was given." % (str(type(data)),),
):
dataframe_regression.check(data)


def test_frame(dataframe_regression):
df = pd.DataFrame.from_records(
[
{"a": "a", "b": "b"},
{"a": "a1", "b": ""},
]
)

dataframe_regression.check(df)
3 changes: 3 additions & 0 deletions tests/test_dataframe_regression/test_frame.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
,a,b
0,a,b
1,a1,