Skip to content

Instantly share code, notes, and snippets.

@mambocab
Last active August 29, 2015 14:16
Show Gist options
  • Save mambocab/364ef25f82d8eed63a2e to your computer and use it in GitHub Desktop.
Save mambocab/364ef25f82d8eed63a2e to your computer and use it in GitHub Desktop.
def nan_infinity_test(self):
cursor = self.prepare()
cursor.execute("CREATE TABLE test (f float PRIMARY KEY)")
cursor.execute("INSERT INTO test(f) VALUES (NaN)")
cursor.execute("INSERT INTO test(f) VALUES (-NaN)")
cursor.execute("INSERT INTO test(f) VALUES (Infinity)")
cursor.execute("INSERT INTO test(f) VALUES (-Infinity)")
assert_all(cursor, "SELECT * FROM test",
[[float("nan")], [float("inf")], [float("-inf")]])
-> assert list_res == expected, "Expected %s from %s, but got %s" % (expected, query, list_res)
(Pdb) list_res
[[nan], [inf], [-inf]]
(Pdb) list_res[0][0]
nan
(Pdb) list_res[0][0]
nan
(Pdb) expected[0][0]
nan
(Pdb) list_res[0][0] == expected[0][0]
False
>>> float('nan') == float('nan')
False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment