Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making sure that TestCase can be hashed #248

Merged
merged 3 commits into from Jul 1, 2022
Merged

Conversation

gone
Copy link
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

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

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

ddormer commented Nov 15, 2018

Ping @jml and @gone :)

@jml
Copy link
Member

jml commented Nov 15, 2018 via email

@Flimm
Copy link

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
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
Contributor Author

gone commented Feb 23, 2022

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

testtools/testcase.py Outdated Show resolved Hide resolved
@gone
Copy link
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.

None yet

7 participants