You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=<Date2010-01-19.00:13:13.363>created_at=<Date2010-01-18.23:24:47.071>labels= ['type-feature', 'tests']
title='Patch all tests to change assertTrue(a [not] in b [, c]) -> assert[Not]In(a, b [,c])'updated_at=<Date2010-01-24.01:16:17.030>user='https://github.com/davidmalcolm'
In many places throughout the existing test suite, there are assertions of the form:
self.assertTrue(chips in menu)
and of the form:
self.assertTrue(cheese not in shop)
If these fail, the error message will merely tell you that the condition failed, without telling you the values.
Some of these tests have an additional handcoded "msg" argument.
The attached patch (to the py3k branch) changes all of these assertions to use the assertIn and assertNotIn methods: when these fail, the log will indicate the repr() of the left- and right- hand sides.
If a "msg" argument was provided which isn't the left or right-hand side, I supply that as a third argument (which these methods can also accept).
I generated this patch using this pair of shell commands:
# Fixup "not in":
find Lib/test -name test_\*.py \
| xargs sed --in-place -r -e "s|self.assertTrue\((.*) not in (.*)\)|self.assertNotIn(\1, \2)|g"
# Fixup "in":
find Lib/test -name test_\*.py \
| xargs sed --in-place -r -e "s|self.assertTrue\((.*) in (.*)\)|self.assertIn(\1, \2)|g"
and then manually fixing the tests until they worked (the above isn't perfect, but was close enough, if I had to do it again I'd write a python script).
I edited some of the basic tests for collections that verify in/not-in semantics, so that both forms of test are present (using the assertIn variant first, to provide better logs in the event of failure. I'm not sure that doing so is meaningful though (assertIn does a "member not in container", and assertNotIn does a "member in container" test).
I've rerun the test on my local build, and verified the code visually (however the patch is rather large so I may have missed something):
75 files changed, 471 insertions(+), 454 deletions(-)
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: