Example #1
0
 def test_summarize_identical(self):
     lhs = [
         {'name': 'a', 'sheep': '7'},
         {'name': 'b', 'sheep': '12'},
         {'name': 'c', 'sheep': '0'},
     ]
     diff = csvdiff.diff_records(lhs, lhs, ['name'])
     assert patch.is_valid(diff)
     assert not patch.is_typed(diff)
     o = StringIO()
     csvdiff._summarize_diff(diff, len(lhs), stream=o)
     self.assertEqual(
         o.getvalue(),
         'files are identical\n'
     )
Example #2
0
 def test_summarize_identical(self):
     lhs = [
         {
             'name': 'a',
             'sheep': '7'
         },
         {
             'name': 'b',
             'sheep': '12'
         },
         {
             'name': 'c',
             'sheep': '0'
         },
     ]
     diff = csvdiff.diff_records(lhs, lhs, ['name'])
     assert patch.is_valid(diff)
     assert not patch.is_typed(diff)
     o = StringIO()
     csvdiff._summarize_diff(diff, len(lhs), stream=o)
     self.assertEqual(o.getvalue(), 'files are identical\n')
Example #3
0
 def test_summarize(self):
     lhs = [
         {'name': 'a', 'sheep': '7'},
         {'name': 'b', 'sheep': '12'},
         {'name': 'c', 'sheep': '0'},
     ]
     rhs = [
         {'name': 'a', 'sheep': '7'},
         {'name': 'c', 'sheep': '2'},
         {'name': 'd', 'sheep': '8'},
     ]
     diff = csvdiff.diff_records(lhs, rhs, ['name'])
     assert patch.is_valid(diff)
     assert not patch.is_typed(diff)
     o = StringIO()
     csvdiff._summarize_diff(diff, len(lhs), stream=o)
     self.assertEqual(
         o.getvalue(),
         "1 rows removed (33.3%)\n"
         "1 rows added (33.3%)\n"
         "1 rows changed (33.3%)\n"
     )
Example #4
0
 def test_summarize(self):
     lhs = [
         {
             'name': 'a',
             'sheep': '7'
         },
         {
             'name': 'b',
             'sheep': '12'
         },
         {
             'name': 'c',
             'sheep': '0'
         },
     ]
     rhs = [
         {
             'name': 'a',
             'sheep': '7'
         },
         {
             'name': 'c',
             'sheep': '2'
         },
         {
             'name': 'd',
             'sheep': '8'
         },
     ]
     diff = csvdiff.diff_records(lhs, rhs, ['name'])
     assert patch.is_valid(diff)
     assert not patch.is_typed(diff)
     o = StringIO()
     csvdiff._summarize_diff(diff, len(lhs), stream=o)
     self.assertEqual(
         o.getvalue(), "1 rows removed (33.3%)\n"
         "1 rows added (33.3%)\n"
         "1 rows changed (33.3%)\n")