Skip to content

Using assertIs in unit tests where appropriate. - #3629

Merged
dhermes merged 2 commits into
googleapis:masterfrom
dhermes:use-assertIs
Jul 19, 2017
Merged

Using assertIs in unit tests where appropriate.#3629
dhermes merged 2 commits into
googleapis:masterfrom
dhermes:use-assertIs

Conversation

@dhermes

Copy link
Copy Markdown
Contributor

Any usage of self.assertTrue(a is b) has become self.assertIs(a, b).

I used a Python script to make this change:

# Produce file via# $ git grep -n assertTrue | grep ' is ' > change_it.txt# Manually made changes for lines with 12 space indent and for# the files in the Speech packageimportcollectionsdefmain():
withopen('change_it.txt', 'r') asfile_obj:
lines=file_obj.read().strip().split('\n')
by_file=collections.defaultdict(dict)
forlineinlines:
filename, line_no, content=line.split(':')
line_no=int(line_no)
in_file=by_file[filename]
ifline_noinin_file:
raiseKeyError('WAT', filename, line_no)
ifcontent[:24] !=' self.assertTrue(':
raiseValueError(line, 'bad 1')
ifcontent[-1] !=')':
raiseValueError(line, 'bad 2')
left, right=content[24:-1].split(' is ')
if' 'inleftor' 'inright:
raiseValueError(line, 'bad 3')
actual=' self.assertIs({}, {})'.format(left, right)
in_file[line_no] = (content, actual)
forfilename, in_fileinby_file.items():
withopen(filename, 'r') asfile_obj:
lines=file_obj.read().split('\n')
forline_no, pairinin_file.items():
assertlines[line_no-1] ==pair[0]
lines[line_no-1] =pair[1]
withopen(filename, 'w') asfile_obj:
file_obj.write('\n'.join(lines))
if__name__=='__main__':
main()

Any usage of `self.assertTrue(a is b)` has become
`self.assertIs(a, b)`.
@googlebotgooglebot added the cla: yes This human has signed the Contributor License Agreement. label Jul 19, 2017
@dhermes
dhermes merged commit 34bf003 into googleapis:masterJul 19, 2017
@dhermes
dhermes deleted the use-assertIs branch July 19, 2017 21:44
landrito pushed a commit to landrito/google-cloud-python that referenced this pull request Aug 21, 2017
* Using assertIs in unit tests where appropriate.
Any usage of `self.assertTrue(a is b)` has become
`self.assertIs(a, b)`.
* Converting some assertFalse(a is b) to assertIsNot(a, b).
landrito pushed a commit to landrito/google-cloud-python that referenced this pull request Aug 22, 2017
* Using assertIs in unit tests where appropriate.
Any usage of `self.assertTrue(a is b)` has become
`self.assertIs(a, b)`.
* Converting some assertFalse(a is b) to assertIsNot(a, b).
landrito pushed a commit to landrito/google-cloud-python that referenced this pull request Aug 22, 2017
* Using assertIs in unit tests where appropriate.
Any usage of `self.assertTrue(a is b)` has become
`self.assertIs(a, b)`.
* Converting some assertFalse(a is b) to assertIsNot(a, b).
atulep pushed a commit that referenced this pull request Apr 3, 2023
* Using assertIs in unit tests where appropriate.
Any usage of `self.assertTrue(a is b)` has become
`self.assertIs(a, b)`.
* Converting some assertFalse(a is b) to assertIsNot(a, b).
atulep pushed a commit that referenced this pull request Apr 18, 2023
* Using assertIs in unit tests where appropriate.
Any usage of `self.assertTrue(a is b)` has become
`self.assertIs(a, b)`.
* Converting some assertFalse(a is b) to assertIsNot(a, b).
parthea pushed a commit that referenced this pull request Oct 22, 2023
* Using assertIs in unit tests where appropriate.
Any usage of `self.assertTrue(a is b)` has become
`self.assertIs(a, b)`.
* Converting some assertFalse(a is b) to assertIsNot(a, b).
parthea pushed a commit that referenced this pull request Mar 9, 2026
* Using assertIs in unit tests where appropriate.
Any usage of `self.assertTrue(a is b)` has become
`self.assertIs(a, b)`.
* Converting some assertFalse(a is b) to assertIsNot(a, b).
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yesThis human has signed the Contributor License Agreement.testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@dhermes@tseaver@lukesneeringer@googlebot