Skip to content

Instantly share code, notes, and snippets.

@tlehman
Created September 21, 2015 23:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tlehman/4f8dde014b1f27664480 to your computer and use it in GitHub Desktop.
Save tlehman/4f8dde014b1f27664480 to your computer and use it in GitHub Desktop.
Redefine true and false in python
# Python boolean fail
# Or how to redefine True and False and win any argument on the internet!
# Love, @tlehman
from unittest import TestCase
class BoolFail(TestCase):
def test_false(self):
True = False
assert True == False
def test_not_true(self):
truetrue = not(not(1==1))
True = False
assert True != truetrue
@tlehman
Copy link
Author

tlehman commented Sep 21, 2015

Run it using py.test like so:

% py.test boolfail.py
============================================================================================= test session starts ==============================================================================================
platform darwin -- Python 2.7.10 -- py-1.4.28 -- pytest-2.7.1
rootdir: /Users/tlehman/tmp/truthiness, inifile:
collected 2 items

boolfail.py ..

=========================================================================================== 2 passed in 0.02 seconds ===========================================================================================

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment