larsyencken / csvdiff

Generate a diff between two tabular datasets expressed in CSV files.
BSD 3-Clause "New" or "Revised" License
132 stars 31 forks source link

Test failure with py3.6 #38

Closed nehaljwani closed 5 years ago

nehaljwani commented 6 years ago
+ python tests/test_csvdiff.py
tests/test_csvdiff.py:146: DeprecationWarning: Please use assertEqual instead.
  self.assertEquals(result.exit_code, 2)
../tmp/build/80754af9/csvdiff_1527844944335/_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_pla/lib/python3.6/site-packages/jsonschema/exceptions.py:30: ResourceWarning: unclosed file <_io.FileIO name=4 mode='rb+' closefd=True>
  super(_Error, self).__init__(
/tmp/build/80754af9/csvdiff_1527844944335/_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_pla/lib/python3.6/site-packages/jsonschema/exceptions.py:30: ResourceWarning: unclosed file <_io.FileIO name=6 mode='rb+' closefd=True>
  super(_Error, self).__init__(
...........F.....
======================================================================
FAIL: test_patch_cmd_valid_args (__main__.TestCsvdiff)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests/test_csvdiff.py", line 334, in test_patch_cmd_valid_args
    self.assertRecordsEqual(result.records, expected)
  File "tests/test_csvdiff.py", line 398, in assertRecordsEqual
    self.assertEqual(records.sort(lhs), records.sort(rhs))
AssertionError: Lists differ: [Orde[19 chars]), ('amount', '13'), ('name', 'fred')]), Order[244 chars]')])] != [Orde[19 chars]), ('name', 'fred'), ('amount', '13')]), Order[244 chars]')])]

First differing element 0:
OrderedDict([('id', '6'), ('amount', '13'), ('name', 'fred')])
OrderedDict([('id', '6'), ('name', 'fred'), ('amount', '13')])
larsyencken commented 5 years ago

It's because from Python 3.6 onwards, the CSV module began providing ordered dictionaries instead of unordered ones.

It's fixed now in the tests. We ignore column ordering in csvdiff.