diff options
author | Nick Vatamaniuc <vatamane@apache.org> | 2018-10-03 15:11:57 -0400 |
---|---|---|
committer | Nick Vatamaniuc <vatamane@apache.org> | 2018-11-26 17:49:33 -0500 |
commit | 9870a7c0aa1801bd30f19f8abfc3fbe8d45bae12 (patch) | |
tree | 57d1e1557f0fe99aecec4bc86cfb97fc88e513f4 | |
parent | 2a3467d51415569e5f93c0cf4afbc5bbcd1ba17b (diff) | |
download | couchdb-9870a7c0aa1801bd30f19f8abfc3fbe8d45bae12.tar.gz |
Run mango tests with Python 3
Before we were ignoring venv setup in the Makefile, so update the test runner
to use that instead of pestering developers to install those dependencies by
hand.
Issue #1632
-rw-r--r-- | .travis.yml | 7 | ||||
-rw-r--r-- | Makefile | 6 | ||||
-rw-r--r-- | README-DEV.rst | 19 | ||||
-rw-r--r-- | src/mango/Makefile | 56 | ||||
-rw-r--r-- | src/mango/requirements.txt | 4 | ||||
-rw-r--r-- | src/mango/test/02-basic-find-test.py | 2 | ||||
-rw-r--r-- | src/mango/test/04-key-tests.py | 14 | ||||
-rw-r--r-- | src/mango/test/06-basic-text-test.py | 4 | ||||
-rw-r--r-- | src/mango/test/README.md | 8 | ||||
-rw-r--r-- | src/mango/test/mango.py | 2 |
10 files changed, 33 insertions, 89 deletions
diff --git a/.travis.yml b/.travis.yml index 01b2862a3..1349e986e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,7 +26,7 @@ addons: - shunit2 python: - - "2.7" + - "3.4" git: depth: 10 @@ -52,11 +52,6 @@ before_script: - rm -rf /tmp/couchjslogs - mkdir -p /tmp/couchjslogs - ./configure -c --disable-docs --disable-fauxton - - cd src/mango - - make venv - - source venv/bin/activate - - make pip-install - - cd ../.. script: - make check @@ -280,7 +280,11 @@ build-test: .PHONY: mango-test # target: mango-test - Run Mango tests mango-test: devclean all - @cd src/mango && ../../dev/run -n 1 --admin=testuser:testpass nosetests + @cd src/mango && \ + virtualenv --python=python3 venv && \ + . ./venv/bin/activate && \ + pip3 install -r requirements.txt + @cd src/mango && ../../dev/run -n 1 --admin=testuser:testpass ./venv/bin/nosetests ################################################################################ # Developing diff --git a/README-DEV.rst b/README-DEV.rst index 9cfa1f2ef..7f483a7c7 100644 --- a/README-DEV.rst +++ b/README-DEV.rst @@ -14,10 +14,7 @@ Dependencies You need the following to run tests: -* `Python <https://www.python.org/>`_ -* `nose <https://nose.readthedocs.io/en/latest/>`_ -* `requests <http://docs.python-requests.org/>`_ -* `hypothesis <https://pypi.python.org/pypi/hypothesis>`_ +* `Python 3 <https://www.python.org/>`_ You need the following optionally to build documentation: @@ -60,7 +57,7 @@ Debian-based (inc. Ubuntu) Systems :: sudo apt-get install help2man python-sphinx gnupg nodejs npm \ - python-hypothesis python-requests python-nose + python3 python3-virtualenv Gentoo-based Systems ~~~~~~~~~~~~~~~~~~~~ @@ -70,14 +67,14 @@ Gentoo-based Systems sudo emerge gnupg coreutils pkgconfig help2man sphinx python sudo pip install hypothesis requests nose -RedHat-based (Fedora, Centos, RHEL) Systems -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Centos 7 and RHEL 7 +~~~~~~~~~~~~~~~~~~~ :: sudo yum install help2man python-sphinx python-docutils \ - python-pygments gnupg nodejs npm python-nose python-requests \ - python-hypothesis + python-pygments gnupg nodejs npm python34-virtualenv + Mac OS X ~~~~~~~~ @@ -89,7 +86,7 @@ Unless you want to install the optional dependencies, skip to the next section. Install what else we can with Homebrew:: - brew install help2man gnupg md5sha1sum node + brew install help2man gnupg md5sha1sum node python If you don't already have pip installed, install it:: @@ -97,7 +94,7 @@ If you don't already have pip installed, install it:: Now, install the required Python packages:: - sudo pip install sphinx docutils pygments nose requests hypothesis sphinx_rtd_theme + sudo pip install sphinx docutils pygments sphinx_rtd_theme FreeBSD ~~~~~~~ diff --git a/src/mango/Makefile b/src/mango/Makefile deleted file mode 100644 index 59f4a29c2..000000000 --- a/src/mango/Makefile +++ /dev/null @@ -1,56 +0,0 @@ -REBAR?=rebar - - -.PHONY: all -# target: all - Makes everything -all: build - - -.PHONY: build -# target: build - Builds the project -build: - $(REBAR) compile - - -.PHONY: check -# target: check - Checks if project builds and passes all the tests -check: build test - - -.PHONY: clean -# target: clean - Prints this help -clean: - $(REBAR) clean - rm -f test/*.pyc - - -.PHONY: distclean -# target: distclean - Removes all unversioned files -distclean: clean - git clean -fxd - - -.PHONY: help -# target: help - Prints this help -help: - @egrep "^# target:" Makefile | sed -e 's/^# target: //g' | sort - - -.PHONY: test -# target: test - Runs test suite -test: - nosetests - - -.PHONY: pip-install -# target: pip-install - Installs requires Python packages -pip-install: - pip install nose requests - pip install hypothesis==3.79.0 - - -.PHONY: venv -# target: venv - Initializes virtual environment (requires virtualenv) -venv: - virtualenv --python=python2.7 venv - @echo "VirtualEnv has been created. Don't forget to run . venv/bin/active" diff --git a/src/mango/requirements.txt b/src/mango/requirements.txt new file mode 100644 index 000000000..a56acebd0 --- /dev/null +++ b/src/mango/requirements.txt @@ -0,0 +1,4 @@ +nose==1.3.7 +requests==2.20.1 +hypothesis==3.79.0 + diff --git a/src/mango/test/02-basic-find-test.py b/src/mango/test/02-basic-find-test.py index 6a31d33ee..cfb0bae09 100644 --- a/src/mango/test/02-basic-find-test.py +++ b/src/mango/test/02-basic-find-test.py @@ -339,4 +339,4 @@ class BasicFindTests(mango.UserDocsTests): "_id": {"$gt": 0}, "age": {"$gt": 0} }, sort=["_id"], explain=True) - self.assertEquals(explain["index"]["type"], "special") + self.assertEqual(explain["index"]["type"], "special") diff --git a/src/mango/test/04-key-tests.py b/src/mango/test/04-key-tests.py index 4956d4689..29451912d 100644 --- a/src/mango/test/04-key-tests.py +++ b/src/mango/test/04-key-tests.py @@ -75,9 +75,9 @@ class KeyTests(mango.DbPerClass): fields = ["title", "dot\\.key", "none.dot"] def check(docs): assert len(docs) == 4 - assert docs[1].has_key("dot.key") + assert "dot.key" in docs[1] assert docs[1]["dot.key"] == "dot's value" - assert docs[1].has_key("none") + assert "none" in docs[1] assert docs[1]["none"]["dot"] == "none dot's value" self.run_check(query, check, fields=fields) @@ -86,9 +86,9 @@ class KeyTests(mango.DbPerClass): fields = ["title", "$key", "deep.$key"] def check(docs): assert len(docs) == 4 - assert docs[2].has_key("$key") + assert "$key" in docs[2] assert docs[2]["$key"] == "peso" - assert docs[2].has_key("deep") + assert "deep" in docs[2] assert docs[2]["deep"]["$key"] == "deep peso" self.run_check(query, check, fields=fields) @@ -98,8 +98,8 @@ class KeyTests(mango.DbPerClass): def check(docs): assert len(docs) == 4 # note: == \uf8ff - assert docs[3].has_key(u'\uf8ff') - assert docs[3][u'\uf8ff'] == "apple" + assert '\uf8ff' in docs[3] + assert docs[3]['\uf8ff'] == "apple" self.run_check(query, check, fields=fields) # The rest of these tests are only run against the text @@ -110,7 +110,7 @@ class KeyTests(mango.DbPerClass): query = {"" : "apple"} def check(docs): assert len(docs) == 1 - assert docs[0][u"\uf8ff"] == "apple" + assert docs[0]["\uf8ff"] == "apple" self.run_check(query, check, indexes=["text"]) def test_internal_field_tests(self): diff --git a/src/mango/test/06-basic-text-test.py b/src/mango/test/06-basic-text-test.py index 3783006ab..d48948bae 100644 --- a/src/mango/test/06-basic-text-test.py +++ b/src/mango/test/06-basic-text-test.py @@ -285,7 +285,7 @@ class BasicTextTests(mango.UserDocsTextTests): assert d["user_id"] in (1, 9) # Limits on boolean clauses? - docs = self.db.find({"age": {"$in": range(1000)}}) + docs = self.db.find({"age": {"$in": list(range(1000))}}) assert len(docs) == 15 def test_in_with_array(self): @@ -323,7 +323,7 @@ class BasicTextTests(mango.UserDocsTextTests): assert d["user_id"] not in (1, 9) # Limits on boolean clauses? - docs = self.db.find({"age": {"$nin": range(1000)}}) + docs = self.db.find({"age": {"$nin": list(range(1000))}}) assert len(docs) == 0 def test_nin_with_array(self): diff --git a/src/mango/test/README.md b/src/mango/test/README.md index 3c99cab9d..3e75f72d1 100644 --- a/src/mango/test/README.md +++ b/src/mango/test/README.md @@ -5,10 +5,10 @@ CouchDB should be started with `./dev/run -a testuser:testpass`. To run these, do this in the Mango top level directory: - $ virtualenv venv - $ source venv/bin/activate - $ make pip-install - $ make test + $ virtualenv --python=python3 venv + $ . venv/bin/activate + $ pip3 install -r requirements.txt + $ ./venv/bin/nosetests To run an individual test suite: nosetests --nocapture test/12-use-correct-index.py diff --git a/src/mango/test/mango.py b/src/mango/test/mango.py index 59486c861..dfe220d2b 100644 --- a/src/mango/test/mango.py +++ b/src/mango/test/mango.py @@ -67,7 +67,7 @@ class Database(object): return "{}/{}".format(self.root_url, self.dbname) def path(self, parts): - if isinstance(parts, ("".__class__, u"".__class__)): + if isinstance(parts, ("".__class__, "".__class__)): parts = [parts] return "/".join([self.url] + parts) |