Skip to content

Commit 4c9acb9

Browse files
authored
Identity is not the same thing as equality in Python
Identity is not the same thing as equality in Python. In this instance, we want the latter. Use ==/!= to compare str, bytes, and int literals. $ __python__ ```python >>> result = 'choic' >>> result += 'e' >>> result == 'choice' True >>> result is 'choice' False ```
1 parent a45f7ac commit 4c9acb9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

readthedocs/config/tests/test_validation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class TestValidateChoice:
4343

4444
def test_it_accepts_valid_choice(self):
4545
result = validate_choice('choice', ('choice', 'another_choice'))
46-
assert result is 'choice'
46+
assert result == 'choice'
4747

4848
with raises(ValidationError) as excinfo:
4949
validate_choice('c', 'abc')

0 commit comments

Comments
 (0)