homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: assertSequenceEqual does not use _getAssertEqualityFunc
Type: behavior Stage: resolved
Components: Tests Versions: Python 3.9, Python 3.6
process
Status: closed Resolution: duplicate
Dependencies: Superseder: addTypeEqualityFunc is not used in assertListEqual
View: 22452
Assigned To: Nosy List: Rarity, ezio.melotti, iritkatriel, jack__d, michael.foord, rbcollins
Priority: normal Keywords:

Created on 2021年08月03日 20:24 by Rarity, last changed 2022年04月11日 14:59 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
example.py Rarity, 2021年08月04日 16:34
Messages (5)
msg398851 - (view) Author: Brian (Rarity) * Date: 2021年08月03日 20:24
Like the title says, TestCase.assertSequenceEqual does not behave like TestCase.assertEqual where it uses TestCase._getAssertEqualityFunc. Instead, TestCase.assertSequenceEqual uses `item1 != item2`. That way I can do something like this:
```
def test_stuff(self):
 self.addTypeEqualityFunc(
 MyObject,
 comparison_method_which_compares_how_i_want,
 )
 self.assertListEqual(
 get_list_of_objects(),
 [MyObject(...), MyObject(...)],
 )
```
msg398860 - (view) Author: Jack DeVries (jack__d) * Date: 2021年08月04日 04:31
Brian, can you be more specific about what problem is caused by the fact that assertSequenceEqual does not use _getAssertEqualityFunc? Also, I'm not sure what your example is trying to demonstrate. Can you provide a minimal example that shows the problem, but also defines what ``MyObject``, etc. are?
Let me know if I'm missing something.
msg398891 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2021年08月04日 11:47
That's correct, and apparently not mentioned in the doc: https://docs.python.org/3/library/unittest.html#unittest.TestCase.assertSequenceEqual 
msg398911 - (view) Author: Brian (Rarity) * Date: 2021年08月04日 16:34
I've attached an example of what I want. It contains a class, a function to be tested, and a test class which tests the function.
What TestCase.addTypeEqualityFunc feels like it offers is a chance to compare objects however I feel like is needed for each test. Sometimes all I want is to compare the properties of the objects, and maybe not even all of the properties! When I have a list of these objects and I've added an equality function for the object, I was expecting the test class to use my equality function when comparing objects in the list.
msg399198 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2021年08月07日 19:03
Closing as duplicate of issue22452.
History
Date User Action Args
2022年04月11日 14:59:48adminsetgithub: 88982
2021年08月07日 19:03:39iritkatrielsetstatus: open -> closed

messages: + msg399198
stage: resolved
2021年08月04日 17:40:20iritkatrielsetsuperseder: addTypeEqualityFunc is not used in assertListEqual
resolution: duplicate
2021年08月04日 16:34:06Raritysetfiles: + example.py

messages: + msg398911
2021年08月04日 11:47:48iritkatrielsetnosy: + rbcollins, iritkatriel, ezio.melotti, michael.foord
messages: + msg398891
2021年08月04日 04:31:33jack__dsetnosy: + jack__d
messages: + msg398860
2021年08月03日 20:24:40Raritycreate

AltStyle によって変換されたページ (->オリジナル) /