You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by to...@apache.org on 2015/09/10 20:33:03 UTC
couchdb-mango git commit: Shorten tests
Repository: couchdb-mango
Updated Branches:
refs/heads/2787-modify-testcases 2793b9f50 -> 87bde010f
Shorten tests
COUCHDB-2787
Project: http://git-wip-us.apache.org/repos/asf/couchdb-mango/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-mango/commit/87bde010
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-mango/tree/87bde010
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-mango/diff/87bde010
Branch: refs/heads/2787-modify-testcases
Commit: 87bde010f80719c91ff8ae3fbbe2ec984acb77be
Parents: 2793b9f
Author: Tony Sun <to...@cloudant.com>
Authored: Thu Sep 10 11:34:45 2015 -0700
Committer: Tony Sun <to...@cloudant.com>
Committed: Thu Sep 10 11:34:45 2015 -0700
----------------------------------------------------------------------
test/06-basic-text-test.py | 50 ++++++++++++-----------------------------
1 file changed, 14 insertions(+), 36 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/87bde010/test/06-basic-text-test.py
----------------------------------------------------------------------
diff --git a/test/06-basic-text-test.py b/test/06-basic-text-test.py
index 53e9159..8ed09f9 100644
--- a/test/06-basic-text-test.py
+++ b/test/06-basic-text-test.py
@@ -14,9 +14,9 @@ import json
import mango
import unittest
import user_docs
-import copy
+import math
import num_string_docs
-from hypothesis import given, assume
+from hypothesis import given, assume, example
import hypothesis.strategies as st
@unittest.skipIf(mango.has_text_service(), "text service exists")
@@ -567,43 +567,21 @@ class NumStringTests(mango.DbPerClass):
klass.db.recreate()
klass.db.create_text_index()
- def test_nan_val(self):
- doc = {"number_NaN": "NaN"}
- self.db.save_doc(doc)
- q = {"$text": "NaN"}
- docs = self.db.find(q)
- print docs
- assert docs[0]["number_NaN"] == "NaN"
-
- def test_infinity_val(self):
- doc = {"number_Infinity": "Infinity"}
- self.db.save_doc(doc)
- q = {"$text": "Infinity"}
- docs = self.db.find(q)
- assert docs[0]["number_Infinity"] == "Infinity"
-
- @given(float_point_string=st.floats().map(str))
- def test_floating_point_val(self,float_point_string):
- assume(float_point_string!="nan")
- doc = {"number_string": float_point_string}
- self.db.save_doc(doc)
- q = {"$text": float_point_string}
- docs = self.db.find(q)
- if len(docs) == 1:
- assert docs[0]["number_string"] == float_point_string
- if len(docs) == 2:
- if docs[0]["number_string"] != float_point_string:
- assert docs[1]["number_string"] == float_point_string
+ # not available for python 2.7.x
+ def isFinite(num):
+ not (math.isinf(num) or math.isnan(num))
- @given(f=st.floats())
+ @given(f=st.floats().filter(isFinite).map(str)
+ | st.floats().map(lambda f: f.hex()))
+ @example('NaN')
+ @example('Infinity')
def test_floating_point_val(self,f):
- hex_float_point_string = f.hex()
- doc = {"number_string": hex_float_point_string}
+ doc = {"number_string": f}
self.db.save_doc(doc)
- q = {"$text": hex_float_point_string}
+ q = {"$text": f}
docs = self.db.find(q)
if len(docs) == 1:
- assert docs[0]["number_string"] == hex_float_point_string
+ assert docs[0]["number_string"] == f
if len(docs) == 2:
- if docs[0]["number_string"] != hex_float_point_string:
- assert docs[1]["number_string"] == hex_float_point_string
+ if docs[0]["number_string"] != f:
+ assert docs[1]["number_string"] == f