# HG changeset patch # User Amine Sehili # Date 1557164614 -3600 # Node ID 6e574fa1b573bd1a4689f25b6170610428c1f6db # Parent 3cb0bbcc262d610cdad2bf1f9ddcf29db300f0d8 Implement __eq__ in AudioRegion diff -r 3cb0bbcc262d -r 6e574fa1b573 auditok/core.py --- a/auditok/core.py Sat May 04 17:21:07 2019 +0100 +++ b/auditok/core.py Mon May 06 18:43:34 2019 +0100 @@ -410,6 +410,18 @@ def __rmul__(self, n): return self * n + def __eq__(self, other): + if other is self: + return True + if not isinstance(other, AudioRegion): + return False + return ( + (self._data == other._data) + and (self.sr == other.sr) + and (self.sw == other.sw) + and (self.ch == other.ch) + ) + def __getitem__(self, index): err_message = "AudioRegion index must a slice object without a step" if not isinstance(index, slice): diff -r 3cb0bbcc262d -r 6e574fa1b573 tests/test_core.py --- a/tests/test_core.py Sat May 04 17:21:07 2019 +0100 +++ b/tests/test_core.py Mon May 06 18:43:34 2019 +0100 @@ -475,12 +475,9 @@ self.assertEqual(m_region.duration, expected_duration) self.assertEqual(len(m_region), expected_length) - @genty_dataset( - _str=("x", "str"), - _float=(1.4, "float"), - ) + @genty_dataset(_str=("x", "str"), _float=(1.4, "float")) def test_multiplication_non_int(self, factor, _type): with self.assertRaises(TypeError) as type_err: - AudioRegion(b'0' * 80, 0, 8000, 1, 1) * factor + AudioRegion(b"0" * 80, 0, 8000, 1, 1) * factor err_msg = "Can't multiply AudioRegion by a non-int of type '{}'" self.assertEqual(err_msg.format(_type), str(type_err.exception))