diff --git a/.bumpversion.cfg b/.bumpversion.cfg index cba1ebf..1e2ab25 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 2.0.11 +current_version = 2.0.12 commit = False tag = False tag_name = "v{new_version}" diff --git a/.gitignore b/.gitignore index f4394de..6c7a491 100644 --- a/.gitignore +++ b/.gitignore @@ -5,13 +5,15 @@ build *.pyc node_modules -tests/source/*_java/target +functionaltests/source/*_java/target quark/output output/ +QUARK_VERSION-dirty.txt venv virtualenv +virtualenv3 build-tools # KDE @@ -31,4 +33,4 @@ build-tools .cache npm-debug.log -dist/ \ No newline at end of file +dist/ diff --git a/.travis-test.sh b/.travis-test.sh index 68c8e94..136c5e8 100755 --- a/.travis-test.sh +++ b/.travis-test.sh @@ -11,17 +11,5 @@ gem --version # Prepare virtualenv: make setup -# Enter the virtualenv: -source virtualenv/bin/activate - -echo "Git commit is:" $TRAVIS_COMMIT -for CODE_LANG in --python --ruby --java --javascript ; do - echo "Language is:" $CODE_LANG - bash install.sh $CODE_LANG $TRAVIS_COMMIT -done - -# Make sure we can build packages, if not there's no point in even continuing: -make packages - # Run the tests: make test diff --git a/Makefile b/Makefile index c2bc200..396b4cc 100644 --- a/Makefile +++ b/Makefile @@ -9,29 +9,66 @@ default: echo "* 'make release-patch' to do a patch release (2.0.x)" echo "* 'make release-minor' to do a minor release (2.x.0)" echo "* 'make upload-packages' to upload packages to native repos (e.g. .whl to PyPI, .gem to RubyGems.org, etc.)" + echo "* 'make clean' to undo setup and packages" + +.PHONY: clean +clean: + rm -fr virtualenv + rm -fr virtualenv3 + rm -fr output + rm -fr dist + rm -f quark/*.qc + rm -fr ~/.m2/repository/datawire_mdk + rm -fr ~/.m2/repository/io/datawire/mdk virtualenv: - virtualenv virtualenv + virtualenv -p python2 virtualenv .PHONY: python-dependencies python-dependencies: virtualenv virtualenv/bin/pip install -r dev-requirements.txt +virtualenv3: + virtualenv -p python3 virtualenv3 + +.PHONY: python3-dependencies +python3-dependencies: virtualenv3 + virtualenv3/bin/pip install -r dev-requirements.txt + .PHONY: setup -setup: python-dependencies +setup: python-dependencies python3-dependencies install-quark + +.PHONY: install-quark +install-quark: + which quark || \ + curl -# -L https://raw.githubusercontent.com/datawire/quark/master/install.sh | \ + bash -s -- -q `cat QUARK_VERSION.txt` + +.PHONY: install-mdk +install-mdk: packages + virtualenv/bin/pip install --upgrade dist/datawire_mdk-*-py2*-none-any.whl + virtualenv3/bin/pip install --upgrade dist/datawire_mdk-*-*py3-none-any.whl + gem install --no-doc dist/datawire_mdk-*.gem + npm install output/js/mdk-2.0 + cd output/java/mdk-2.0 && mvn install .PHONY: test -test: - # For now we rely on either .travis-test.sh or the user to install the - # MDK. This means tests will fail if you are not on Travis - # or have not installed the MDK. - source virtualenv/bin/activate && py.test -n 4 -v tests +test: install-mdk test-python test-python3 + +.PHONY: test-python +test-python: + virtualenv/bin/py.test -n 4 -v unittests functionaltests + +.PHONY: test-python3 +test-python3: + # Functional tests don't benefit from being run in another language: + virtualenv3/bin/py.test -n 4 -v unittests release-minor: - source virtualenv/bin/activate; python scripts/release.py minor + virtualenv/bin/python scripts/release.py minor release-patch: - source virtualenv/bin/activate; python scripts/release.py patch + virtualenv/bin/python scripts/release.py patch # Packaging commands: output: $(wildcard quark/*.q) dist diff --git a/QUARK_VERSION.txt b/QUARK_VERSION.txt index db54e35..c144c81 100644 --- a/QUARK_VERSION.txt +++ b/QUARK_VERSION.txt @@ -1 +1 @@ -v1.0.406 +v1.0.443 diff --git a/dev-requirements.txt b/dev-requirements.txt index 1cebe3e..f3e0c2b 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -5,3 +5,4 @@ travispy==0.3.5 twine==1.8.1 pytest==3.0.1 pytest-xdist==1.15.0 +future==0.15.2 diff --git a/functionaltests/conftest.py b/functionaltests/conftest.py new file mode 100644 index 0000000..5cc75e7 --- /dev/null +++ b/functionaltests/conftest.py @@ -0,0 +1,40 @@ +from __future__ import print_function + +import os +from subprocess import check_call +import pytest + +ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +official = open(os.path.join(ROOT_DIR, "QUARK_VERSION.txt")).read().strip() +try: + dirty = open(os.path.join(ROOT_DIR, "QUARK_VERSION-dirty.txt")).read().strip() + QUARK_VERSION = dirty + QUARK_VERSION_STATUS = "Overriding the quark version %s with the local quark version %s" % (official, dirty) +except IOError: + QUARK_VERSION = official + QUARK_VERSION_STATUS = "Testing with quark version %s, QUARK_VERSION-dirty.txt not found" % (official) +# Git tag starts with v, but the Docker tag does not: +if QUARK_VERSION.startswith("v"): + QUARK_VERSION = QUARK_VERSION[1:] + + +def pytest_report_header(config): + return QUARK_VERSION_STATUS + +def run(filepath, language): + """Install and run a Quark test file.""" + docker_path = os.path.join("/code", + filepath[len(ROOT_DIR) + 1:]) + print("Installing and running {} in {}...".format(filepath, language)) + check_call(["sudo", "docker", "run", + # Mount volume into container so Docker can access quark files: + "-v", ROOT_DIR + ":/code",] + + ["datawire/quark-run:" + QUARK_VERSION, "--" + language, '--verbose', docker_path]) + +@pytest.fixture +def quark_run(request): + return run + +@pytest.fixture(params= ["python3", "python", "java", "ruby", "javascript"]) +def quark_language(request): + return request.param diff --git a/tests/source/continue_trace.py b/functionaltests/source/continue_trace.py similarity index 92% rename from tests/source/continue_trace.py rename to functionaltests/source/continue_trace.py index bae57f3..8f86525 100644 --- a/tests/source/continue_trace.py +++ b/functionaltests/source/continue_trace.py @@ -1,4 +1,5 @@ """Write some logs.""" +from __future__ import print_function import sys import time @@ -11,7 +12,7 @@ def got_logs(log_events, context): results = set() for event in log_events.result: - print event.context, event.category, event.text + print(event.context, event.category, event.text) if event.context.traceId in context: results.add((event.category, event.text)) expected = set([("process1", "hello"), ("process2", "world")]) diff --git a/tests/source/register.py b/functionaltests/source/register.py similarity index 92% rename from tests/source/register.py rename to functionaltests/source/register.py index dd30e48..e00adb5 100644 --- a/tests/source/register.py +++ b/functionaltests/source/register.py @@ -1,4 +1,5 @@ """Register a service given on command-line args.""" +from __future__ import print_function import time import sys diff --git a/tests/source/resolve.js b/functionaltests/source/resolve.js similarity index 100% rename from tests/source/resolve.js rename to functionaltests/source/resolve.js diff --git a/tests/source/resolve.py b/functionaltests/source/resolve.py similarity index 100% rename from tests/source/resolve.py rename to functionaltests/source/resolve.py diff --git a/tests/source/resolve.rb b/functionaltests/source/resolve.rb similarity index 100% rename from tests/source/resolve.rb rename to functionaltests/source/resolve.rb diff --git a/tests/source/resolve_java/pom.xml b/functionaltests/source/resolve_java/pom.xml similarity index 98% rename from tests/source/resolve_java/pom.xml rename to functionaltests/source/resolve_java/pom.xml index b601cba..0520730 100644 --- a/tests/source/resolve_java/pom.xml +++ b/functionaltests/source/resolve_java/pom.xml @@ -80,7 +80,7 @@ 3.4.0-RC1 - datawire_mdk + io.datawire.mdk datawire_mdk [2.0.0,2.1.0) diff --git a/tests/source/resolve_java/src/main/java/Resolve.java b/functionaltests/source/resolve_java/src/main/java/Resolve.java similarity index 100% rename from tests/source/resolve_java/src/main/java/Resolve.java rename to functionaltests/source/resolve_java/src/main/java/Resolve.java diff --git a/tests/source/start_trace.py b/functionaltests/source/start_trace.py similarity index 100% rename from tests/source/start_trace.py rename to functionaltests/source/start_trace.py diff --git a/tests/source/write_logs.js b/functionaltests/source/write_logs.js similarity index 100% rename from tests/source/write_logs.js rename to functionaltests/source/write_logs.js diff --git a/tests/source/write_logs.py b/functionaltests/source/write_logs.py similarity index 89% rename from tests/source/write_logs.py rename to functionaltests/source/write_logs.py index ffdff76..91e4c28 100644 --- a/tests/source/write_logs.py +++ b/functionaltests/source/write_logs.py @@ -1,10 +1,11 @@ """Write some logs.""" +from __future__ import print_function import sys import time import os import logging -logging.basicConfig(file=sys.stderr, level=logging.DEBUG) +logging.basicConfig(stream=sys.stderr, level=logging.DEBUG) from mdk import start mdk = start() @@ -24,7 +25,7 @@ def got_message(event): print("Took more than 60 seconds, giving up.") os._exit(1) - print(event.category, event.text) + print((event.category, event.text)) if event.category == category: results.add((event.text, event.level)) if expected == results: diff --git a/tests/source/write_logs.rb b/functionaltests/source/write_logs.rb similarity index 100% rename from tests/source/write_logs.rb rename to functionaltests/source/write_logs.rb diff --git a/tests/source/writelogs_java/pom.xml b/functionaltests/source/writelogs_java/pom.xml similarity index 98% rename from tests/source/writelogs_java/pom.xml rename to functionaltests/source/writelogs_java/pom.xml index 082b790..8493c5f 100644 --- a/tests/source/writelogs_java/pom.xml +++ b/functionaltests/source/writelogs_java/pom.xml @@ -80,7 +80,7 @@ 3.4.0-RC1 - datawire_mdk + io.datawire.mdk datawire_mdk [2.0.0,) diff --git a/tests/source/writelogs_java/src/main/java/WriteLogs.java b/functionaltests/source/writelogs_java/src/main/java/WriteLogs.java similarity index 100% rename from tests/source/writelogs_java/src/main/java/WriteLogs.java rename to functionaltests/source/writelogs_java/src/main/java/WriteLogs.java diff --git a/tests/test_endtoend.py b/functionaltests/test_endtoend.py similarity index 88% rename from tests/test_endtoend.py rename to functionaltests/test_endtoend.py index 3edbd71..83c250a 100644 --- a/tests/test_endtoend.py +++ b/functionaltests/test_endtoend.py @@ -1,6 +1,8 @@ """End-to-end tests for the MDK API.""" +from builtins import str import os +import sys import time from random import random from subprocess import Popen, check_output, check_call @@ -13,6 +15,8 @@ def random_string(): return "random_" + str(random())[2:] +def decoded_check_output(*args, **kwargs): + return check_output(*args, **kwargs).decode('utf-8') def run_python(command, extra_args=(), output=False): """ @@ -20,9 +24,9 @@ def run_python(command, extra_args=(), output=False): Returns output if output=True, in which case stderr will cause error. """ - args = ["python", os.path.join(CODE_PATH, command)] + list(extra_args) + args = [sys.executable, os.path.join(CODE_PATH, command)] + list(extra_args) if output: - command = check_output + command = decoded_check_output else: command = check_call return command(args) @@ -40,8 +44,8 @@ def assertRegisteryDiscoverable(test, discover): """ service = random_string() address = random_string() - p = Popen(["python", os.path.join(CODE_PATH, "register.py"), service, address]) - test.addCleanup(lambda: p.terminate()) + p = Popen([sys.executable, os.path.join(CODE_PATH, "register.py"), service, address]) + test.addCleanup(lambda: p.kill()) resolved_address = discover(service) test.assertIn(address, resolved_address) return p, service @@ -94,7 +98,7 @@ def test_discovery(self): """Minimal discovery end-to-end test with a Javascript client.""" assertRegisteryDiscoverable( self, - lambda service: check_output( + lambda service: decoded_check_output( ["node", os.path.join(CODE_PATH, "resolve.js"), service])) @@ -110,7 +114,7 @@ def test_discovery(self): """Minimal discovery end-to-end test with a Javascript client.""" assertRegisteryDiscoverable( self, - lambda service: check_output( + lambda service: decoded_check_output( ["ruby", os.path.join(CODE_PATH, "resolve.rb"), service])) @@ -132,7 +136,7 @@ def test_discovery(self): "package"]) assertRegisteryDiscoverable( self, - lambda service: check_output( + lambda service: decoded_check_output( ["java", "-jar", os.path.join( CODE_PATH,"resolve_java/target/resolve-0.0.1.jar"), service])) diff --git a/functionaltests/test_quark.py b/functionaltests/test_quark.py new file mode 100644 index 0000000..9a7c918 --- /dev/null +++ b/functionaltests/test_quark.py @@ -0,0 +1,32 @@ +""" +Run tests written in Quark. +""" +from __future__ import print_function + +import os +from glob import glob +import pytest + +ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +QUARK_TESTS_DIR = os.path.join(ROOT_DIR, "quark/tests") + +# Tests that don't need to run on all languages: +@pytest.fixture(params=[filename for filename in glob(QUARK_TESTS_DIR + "/*.q") + if not filename.endswith("runtime_test.q")]) +def filepath(request): + return request.param + + +def test_run_python_only(quark_run, filepath): + """Run Quark tests that don't need to run in multiple languages.""" + quark_run(filepath, "python") + +def test_run_python3_only(quark_run, filepath): + """Run Quark tests that don't need to run in multiple languages.""" + quark_run(filepath, "python3") + + +def test_run_all_languages(quark_run, quark_language): + """Run tests that have to be run in all languages.""" + quark_run(os.path.join(QUARK_TESTS_DIR, "runtime_test.q"), quark_language) + diff --git a/quark/discovery-3.0.q b/quark/discovery-3.0.q index 9400c2c..787a92c 100644 --- a/quark/discovery-3.0.q +++ b/quark/discovery-3.0.q @@ -1,6 +1,6 @@ quark 1.0; -package datawire_mdk_discovery 2.0.11; +package datawire_mdk_discovery 2.0.12; include discovery-protocol-3.0.q; include synapse.q; diff --git a/quark/introspection-1.0.q b/quark/introspection-1.0.q index def4907..a84d24d 100644 --- a/quark/introspection-1.0.q +++ b/quark/introspection-1.0.q @@ -1,6 +1,6 @@ quark 1.0; -package datawire_mdk_introspection 2.0.11; +package datawire_mdk_introspection 2.0.12; /* * Copyright 2016 Datawire. All rights reserved. diff --git a/quark/mdk-2.0.q b/quark/mdk-2.0.q index ddc514a..e31af22 100644 --- a/quark/mdk-2.0.q +++ b/quark/mdk-2.0.q @@ -1,6 +1,6 @@ quark 1.0; -package datawire_mdk 2.0.11; +package datawire_mdk 2.0.12; // DATAWIRE MDK diff --git a/quark/mdk_runtime.q b/quark/mdk_runtime.q index fb2a344..fb9d7f4 100644 --- a/quark/mdk_runtime.q +++ b/quark/mdk_runtime.q @@ -1,6 +1,6 @@ quark 1.0; -package datawire_mdk_runtime 2.0.11; +package datawire_mdk_runtime 2.0.12; include actors_core.q; include actors_promise.q; diff --git a/quark/mdk_runtime_files.py b/quark/mdk_runtime_files.py index 4b5263b..1859b89 100644 --- a/quark/mdk_runtime_files.py +++ b/quark/mdk_runtime_files.py @@ -16,12 +16,12 @@ def _mdk_mktempdir(): def _mdk_writefile(path, contents): """Write a file to disk.""" with open(path, "wb") as f: - f.write(contents) + f.write(contents.encode("utf-8")) def _mdk_readfile(path): """Read a file's contents.""" with open(path, "rb") as f: - return f.read() + return f.read().decode("utf-8") def _mdk_deletefile(path): """Delete a file.""" diff --git a/quark/protocol-1.0.q b/quark/protocol-1.0.q index b9352d7..d9148e7 100644 --- a/quark/protocol-1.0.q +++ b/quark/protocol-1.0.q @@ -1,6 +1,6 @@ quark 1.0; -package datawire_mdk_protocol 2.0.11; +package datawire_mdk_protocol 2.0.12; import quark.concurrent; import quark.reflect; diff --git a/quark/tracing-2.0.q b/quark/tracing-2.0.q index c734cf7..9c73936 100644 --- a/quark/tracing-2.0.q +++ b/quark/tracing-2.0.q @@ -1,6 +1,6 @@ quark 1.0; -package datawire_mdk_tracing 2.0.11; +package datawire_mdk_tracing 2.0.12; include protocol-1.0.q; include introspection-1.0.q; diff --git a/quark/util-1.0.q b/quark/util-1.0.q index a54406a..da30d4c 100644 --- a/quark/util-1.0.q +++ b/quark/util-1.0.q @@ -1,6 +1,6 @@ quark 1.0; -package datawire_mdk_util 2.0.11; +package datawire_mdk_util 2.0.12; use js bluebird 3.4.1; include mdk_promises.js; diff --git a/scripts/build-packages.py b/scripts/build-packages.py index 105793b..de1b404 100644 --- a/scripts/build-packages.py +++ b/scripts/build-packages.py @@ -5,13 +5,16 @@ from glob import glob from subprocess import check_call +ROOT_DIR=os.path.dirname(os.path.dirname(os.path.abspath(__file__))) def build_python(package_dir): """Build Python package from the output of quark compile (output/py/mdk-2.0).""" - check_call(["python", "setup.py", "bdist_wheel"], cwd=package_dir) + python = os.path.join(ROOT_DIR, "virtualenv/bin/python2") + assert os.path.exists(python), python + print(python) + check_call([python, "setup.py", "bdist_wheel", "--universal"], cwd=package_dir) return glob(os.path.join(package_dir, "dist/*.whl")) - def build_ruby(package_dir): """Build Ruby packages from the output of quark compile (output/rb/mdk-2.0).""" check_call(["gem", "build", "datawire_mdk.gemspec"], cwd=package_dir) @@ -37,7 +40,9 @@ def main(language, in_directory, out_directory): "java": build_java} results = handlers[language](in_directory) for result in results: - os.rename(result, os.path.join(out_directory, os.path.basename(result))) + target = os.path.join(out_directory, os.path.basename(result)) + print("Moving %s to %s" % (result, target)) + os.rename(result, target) if __name__ == '__main__': main(sys.argv[1], sys.argv[2], sys.argv[3]) diff --git a/scripts/release.py b/scripts/release.py index f248d56..cbf78a2 100644 --- a/scripts/release.py +++ b/scripts/release.py @@ -33,6 +33,7 @@ HELP = __doc__ +import sys from subprocess import check_output, CalledProcessError from docopt import docopt @@ -52,7 +53,7 @@ def ensure_not_dirty(options): def ensure_passing_tests(options): """Talk to Travis CI, ensure all tests passed for the current git commit.""" try: - check_output(["python", "scripts/check-travis.py"]) + check_output([sys.executable, "scripts/check-travis.py"]) except CalledProcessError: # check-travis.py will print reason raise SystemExit(1) diff --git a/tests/test_quark.py b/tests/test_quark.py deleted file mode 100644 index cedc4c6..0000000 --- a/tests/test_quark.py +++ /dev/null @@ -1,47 +0,0 @@ -""" -Run tests written in Quark. -""" - -import os -from glob import glob -from subprocess import check_call -import pytest - -ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) -QUARK_TESTS_DIR = os.path.join(ROOT_DIR, "quark/tests") -QUARK_VERSION = open(os.path.join(ROOT_DIR, "QUARK_VERSION.txt")).read().strip() -# Git tag starts with v, but the Docker tag does not: -if QUARK_VERSION.startswith("v"): - QUARK_VERSION = QUARK_VERSION[1:] - - -# Tests that don't need to run on all languages: -@pytest.fixture(params=[filename for filename in glob(QUARK_TESTS_DIR + "/*.q") - if not filename.endswith("runtime_test.q")]) -def filepath(request): - return request.param - -@pytest.fixture(params= ["python", "java", "ruby", "javascript"]) -def language(request): - return request.param - - -def test_run_python_only(filepath): - """Run Quark tests that don't need to run in multiple languages.""" - run(filepath, "python") - - -def test_run_all_languages(language): - """Run tests that have to be run in all languages.""" - run(os.path.join(QUARK_TESTS_DIR, "runtime_test.q"), language) - - -def run(filepath, language): - """Install and run a Quark test file.""" - docker_path = os.path.join("/code/quark/tests", - filepath[len(QUARK_TESTS_DIR) + 1:]) - print("Installing and running {} in {}...".format(filepath, language)) - check_call(["sudo", "docker", "run", - # Mount volume into container so Docker can access quark files: - "-v", ROOT_DIR + ":/code", - "datawire/quark-run:" + QUARK_VERSION, "--" + language, docker_path]) diff --git a/tests/__init__.py b/unittests/__init__.py similarity index 100% rename from tests/__init__.py rename to unittests/__init__.py diff --git a/tests/common.py b/unittests/common.py similarity index 100% rename from tests/common.py rename to unittests/common.py diff --git a/tests/test_actors.py b/unittests/test_actors.py similarity index 99% rename from tests/test_actors.py rename to unittests/test_actors.py index 9892c34..495df5d 100644 --- a/tests/test_actors.py +++ b/unittests/test_actors.py @@ -3,6 +3,7 @@ """ from __future__ import absolute_import +from builtins import object from unittest import TestCase diff --git a/tests/test_dependency.py b/unittests/test_dependency.py similarity index 100% rename from tests/test_dependency.py rename to unittests/test_dependency.py diff --git a/tests/test_discovery.py b/unittests/test_discovery.py similarity index 95% rename from tests/test_discovery.py rename to unittests/test_discovery.py index 0608696..524527a 100644 --- a/tests/test_discovery.py +++ b/unittests/test_discovery.py @@ -5,6 +5,8 @@ """ from __future__ import absolute_import +from builtins import range +from builtins import object from unittest import TestCase @@ -125,7 +127,7 @@ def test_replace(self): disco.onMessage(None, NodeActive(node1)) disco.onMessage(None, NodeActive(node2)) disco.onMessage(None, ReplaceCluster("myservice", [node3, node4])) - self.assertItemsEqual(disco.knownNodes("myservice"), [node3, node4]) + self.assertEqual(disco.knownNodes("myservice"), [node3, node4]) def test_replaceEmpty(self): """ @@ -135,7 +137,7 @@ def test_replaceEmpty(self): node1 = create_node("somewhere") node2 = create_node("somewhere2") disco.onMessage(None, ReplaceCluster("myservice", [node1, node2])) - self.assertItemsEqual(disco.knownNodes("myservice"), [node1, node2]) + self.assertEqual(disco.knownNodes("myservice"), [node1, node2]) def test_replaceTriggersWaitingPromises(self): """ @@ -301,7 +303,7 @@ def __init__(self): self.services = {} def is_empty(self): - return all([not addresses for addresses in self.services.values()]) + return all([not addresses for addresses in list(self.services.values())]) def add(self, service, address): self.services.setdefault(service, set()).add(address) @@ -318,7 +320,7 @@ def replace(self, service, addresses): def compare(self, real_discovery): """Compare us to a real Discovery instance, assert same state.""" real_services = {} - for name, cluster in real_discovery.services.items(): + for name, cluster in list(real_discovery.services.items()): real_services[name] = set(node.address for node in cluster.nodes) assert self.services == real_services @@ -344,17 +346,17 @@ def get_address(service_name): return st.tuples(st.just(service_name), st.sampled_from( self.fake.services[service_name])) return st.tuples(st.just("remove"), ( - st.sampled_from(self.fake.services.keys()).flatmap(get_address))) + st.sampled_from(list(self.fake.services.keys())).flatmap(get_address))) def steps(self): result = add_strategy | replace_strategy # Replace or add to a known service cluster: if self.fake.services: result |= st.tuples(st.just("replace"), - st.tuples(st.sampled_from(self.fake.services.keys()), + st.tuples(st.sampled_from(list(self.fake.services.keys())), st.lists(nice_strings))) result |= st.tuples(st.just("add"), - st.tuples(st.sampled_from(self.fake.services.keys()), + st.tuples(st.sampled_from(list(self.fake.services.keys())), nice_strings)) # Remove a known address from known cluster: if not self.fake.is_empty(): diff --git a/tests/test_mdk.py b/unittests/test_mdk.py similarity index 99% rename from tests/test_mdk.py rename to unittests/test_mdk.py index 46efeb9..992d6f1 100644 --- a/tests/test_mdk.py +++ b/unittests/test_mdk.py @@ -1,6 +1,8 @@ """ Tests for the MDK public API that are easier to do in Python. """ +from builtins import range +from builtins import object from unittest import TestCase from tempfile import mkdtemp diff --git a/tests/test_synapse.py b/unittests/test_synapse.py similarity index 98% rename from tests/test_synapse.py rename to unittests/test_synapse.py index f3aafae..4946d1b 100644 --- a/tests/test_synapse.py +++ b/unittests/test_synapse.py @@ -64,7 +64,7 @@ def get_attrs(l): for n in l: result.append((n.service, n.address, n.version, n.properties)) return result - self.assertItemsEqual(get_attrs(first), get_attrs(second)) + self.assertEqual(get_attrs(first), get_attrs(second)) def test_newFile(self): """A new file in the correct format updates Discovery."""