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/87faac11
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-mango/tree/87faac11
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-mango/diff/87faac11
Branch: refs/heads/master
Commit: 87faac11d7c5c0fd99d5d0eae4d6263ab965d694
Parents: 2793b9f
Author: Tony Sun
Authored: Thu Sep 10 11:34:45 2015 -0700
Committer: Tony Sun
Committed: Fri Sep 11 09:14:54 2015 -0700
--
.travis.yml| 2 +-
Makefile | 1 +
test/06-basic-text-test.py | 54 -
test/mango.py | 9 ---
4 files changed, 18 insertions(+), 48 deletions(-)
--
http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/87faac11/.travis.yml
--
diff --git a/.travis.yml b/.travis.yml
index 04fdb33..2c6b2f0 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -9,7 +9,7 @@ before_install:
- cp -R ../src ./src/mango
- make
- cd ..
- - couchdb/dev/run -n 1 --with-admin-party-please &
+ - couchdb/dev/run -n 1 --admin=testuser:testpass &
- sleep 10
before_script:
http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/87faac11/Makefile
--
diff --git a/Makefile b/Makefile
index 8c136c1..1b2a504 100644
--- a/Makefile
+++ b/Makefile
@@ -46,6 +46,7 @@ test:
# target: pip-install - Installs requires Python packages
pip-install:
pip install nose requests
+ pip install hypothesis
.PHONY: venv
http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/87faac11/test/06-basic-text-test.py
--
diff --git a/test/06-basic-text-test.py b/test/06-basic-text-test.py
index 53e9159..28c495a 100644
--- a/test/06-basic-text-test.py
+++ b/test/06-basic-text-test.py
@@ -14,9 +14,8 @@ import json
import mango
import unittest
import user_docs
-import copy
-import num_string_docs
-from hypothesis import given, assume
+import math
+from hypothesis import given, assume, example
import hypothesis.strategies as st
@unittest.skipIf(mango.has_text_service(), "text service exists")
@@ -565,45 +564,24 @@ class NumStringTests(mango.DbPerClass):
def setUpClass(klass):
super(NumStringTests, klass).setUpClass()
klass.db.recreate()
-klass.db.create_text_index()
+if mango.has_text_service():
+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
http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/87faac11/test/mango.py
--
diff --git a/test/mango.py b/