Skip to content

Making sure that TestCase can be hashed#248

Merged
jelmer merged 3 commits intotesting-cabal:masterfrom
gone:master
Jul 1, 2022
Merged

Making sure that TestCase can be hashed#248
jelmer merged 3 commits intotesting-cabal:masterfrom
gone:master

Conversation

@gone
Copy link
Copy Markdown
Contributor

@gone gone commented Jan 22, 2017

Defining a custom eq method will prevent a TestCase instance from being hashed, and the django testing library attempts to hash all TestCases.

@ddormer
Copy link
Copy Markdown

ddormer commented Mar 1, 2018

I don't think the hash should default to self.id because that will result in each test having the same hash. Instead __hash__ should be set to unittest.TestCase.__hash__.

@javiromero
Copy link
Copy Markdown

I'm facing the exact same issue when running Django 1.11.x tests with Python 3. Is there any chance this gets merged?

@ddormer
Copy link
Copy Markdown

ddormer commented Nov 15, 2018

Ping @jml and @gone :)

@jml
Copy link
Copy Markdown
Member

jml commented Nov 15, 2018 via email

@Flimm
Copy link
Copy Markdown

Flimm commented Aug 23, 2019

This looks useful to me! While waiting for the merge, I guess I can copy and paste the __hash__ implementation.

@gone
Copy link
Copy Markdown
Contributor Author

gone commented Aug 29, 2019

@ddormer sorry about ghosting - missed the notification for this.

I see what you mean about using every test within the same case having the same id, but that's only going to be used if unittest.TestCase.__hash__ isn't set - so it will prefer unittest.testcase if it's present and only all back to id if it's not there.

What's a good default to use when unittest.TestCase.__hash__ is None?

@gone
Copy link
Copy Markdown
Contributor Author

gone commented Feb 23, 2022

Bumping this up - been more active lately if there's desire to get this merged

Comment thread testtools/testcase.py Outdated
@gone
Copy link
Copy Markdown
Contributor Author

gone commented May 1, 2022

Updated - let me know if you'd like me to squash

@jelmer jelmer force-pushed the master branch 2 times, most recently from a74f0b4 to 313dead Compare July 1, 2022 18:32
@jelmer jelmer merged commit 4c352be into testing-cabal:master Jul 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants