Skip to content

Commit

Permalink
Merge pull request #74 from tarcisiofischer/empty-str-bugfix
Browse files Browse the repository at this point in the history
Fix empty string bug on dataframe regression
  • Loading branch information
tarcisiofischer authored Sep 15, 2021
2 parents 983a6db + 24b34c3 commit f92c699
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
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,

0 comments on commit f92c699

Please sign in to comment.