diff options
author | Joan Touzet <wohali@users.noreply.github.com> | 2018-11-27 22:54:21 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-27 22:54:21 -0500 |
commit | fd03aa409a5a040f98eb934df3c4cd5d5bf1acd9 (patch) | |
tree | f0aa0d43ad74b6fbb011bcb86626ab5716ba94e2 | |
parent | 1347806d2feebce53325070b475f9e211d240ddf (diff) | |
parent | d0f76b9f7f93e3843c8bc202dacc5e082e571547 (diff) | |
download | couchdb-fd03aa409a5a040f98eb934df3c4cd5d5bf1acd9.tar.gz |
Merge pull request #1764 from apache/switch-scripts-to-python3
* Switch scripts to python3
* Update mango test harness to use venv
-rw-r--r-- | .travis.yml | 19 | ||||
-rw-r--r-- | Makefile | 5 | ||||
-rw-r--r-- | Makefile.win | 5 | ||||
-rw-r--r-- | README-DEV.rst | 19 | ||||
-rwxr-xr-x | build-aux/logfile-uploader.py | 4 | ||||
-rwxr-xr-x | dev/run | 11 | ||||
-rwxr-xr-x | rel/overlay/bin/couchup | 4 | ||||
-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 | ||||
-rwxr-xr-x | test/javascript/run | 2 |
15 files changed, 52 insertions, 107 deletions
diff --git a/.travis.yml b/.travis.yml index 01b2862a3..a8ed1d5a8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: erlang -sudo: false - os: linux +dist: trusty + otp_release: - 21.1 - 20.3 @@ -18,16 +18,14 @@ addons: - libicu-dev - libmozjs185-dev - pkg-config - - python-requests - - python-sphinx - - python-virtualenv + - python3 + - python3-requests + - python3-sphinx + - python3.4-venv # - sphinx-rtd-theme - help2man - shunit2 -python: - - "2.7" - git: depth: 10 @@ -52,11 +50,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,10 @@ 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 && \ + python3 -m venv venv && \ + venv/bin/pip3 install -r requirements.txt + @cd src/mango && ../../dev/run -n 1 --admin=testuser:testpass venv/bin/nosetests ################################################################################ # Developing diff --git a/Makefile.win b/Makefile.win index e93445e59..6b62ba9fd 100644 --- a/Makefile.win +++ b/Makefile.win @@ -201,7 +201,10 @@ endif .PHONY: mango-test mango-test: devclean all - @cd src\mango && ..\..\dev\run -n 1 --admin=testuser:testpass nosetests + @cd src\mango && \ + python.exe -m venv venv && \ + venv\Scripts\pip.exe install -r requirements.txt + @cd src\mango && venv\Scripts\python.exe ..\..\dev\run -n 1 --admin=testuser:testpass venv\Scripts\nosetests .PHONY: check-qs diff --git a/README-DEV.rst b/README-DEV.rst index 9cfa1f2ef..f4031b767 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-venv 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 + 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/build-aux/logfile-uploader.py b/build-aux/logfile-uploader.py index a1ff7e4a7..c95eab532 100755 --- a/build-aux/logfile-uploader.py +++ b/build-aux/logfile-uploader.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 # # Licensed under the Apache License, Version 2.0 (the "License"); you may not # use this file except in compliance with the License. You may obtain a copy of @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations under # the License. -from __future__ import print_function + import datetime import glob @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Licensed under the Apache License, Version 2.0 (the "License"); you may not # use this file except in compliance with the License. You may obtain a copy of @@ -34,12 +34,12 @@ from pbkdf2 import pbkdf2_hex COMMON_SALT = uuid.uuid4().hex try: - from urllib import urlopen + from urllib.request import urlopen except ImportError: from urllib.request import urlopen try: - import httplib as httpclient + import http.client as httpclient except ImportError: import http.client as httpclient @@ -58,7 +58,8 @@ def log(msg): if log.verbose: sys.stdout.write(chars) sys.stdout.flush() - callargs = dict(list(zip(inspect.getargspec(func).args, args))) + argnames = list(inspect.signature(func).parameters.keys()) + callargs = dict(list(zip(argnames, args))) callargs.update(kwargs) print_('[ * ] ' + msg.format(**callargs) + ' ... ') try: @@ -365,7 +366,7 @@ def boot_nodes(ctx): def ensure_all_nodes_alive(ctx): - status = dict((num, False) for num in range(ctx['N'])) + status = dict((num, False) for num in list(range(ctx['N']))) for _ in range(10): for num in range(ctx['N']): if status[num]: diff --git a/rel/overlay/bin/couchup b/rel/overlay/bin/couchup index 75b7d7e94..41ac4b857 100755 --- a/rel/overlay/bin/couchup +++ b/rel/overlay/bin/couchup @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 # Licensed under the Apache License, Version 2.0 (the "License"); you may not # use this file except in compliance with the License. You may obtain a copy of # the License at @@ -19,7 +19,7 @@ import threading import time import sys try: - from urllib import quote + from urllib.parse import quote except ImportError: from urllib.parse import quote import requests 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..509e32e47 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 + $ python3 -m venv 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) diff --git a/test/javascript/run b/test/javascript/run index ec12431b0..283a7f779 100755 --- a/test/javascript/run +++ b/test/javascript/run @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 # # Licensed under the Apache License, Version 2.0 (the "License"); you may not # use this file except in compliance with the License. You may obtain a copy of |