avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kojirom...@apache.org
Subject [avro] branch master updated: AVRO-2652: Use Tox to Enable Multi Python Testing (#742)
Date Thu, 19 Dec 2019 02:30:58 GMT
This is an automated email from the ASF dual-hosted git repository.

kojiromike pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/avro.git


The following commit(s) were added to refs/heads/master by this push:
     new bd9e6c4  AVRO-2652: Use Tox to Enable Multi Python Testing (#742)
bd9e6c4 is described below

commit bd9e6c4514db274ca97dbf78975a3f9156a523b6
Author: Michael A. Smith <michael@smith-li.com>
AuthorDate: Wed Dec 18 21:30:47 2019 -0500

    AVRO-2652: Use Tox to Enable Multi Python Testing (#742)
    
    * AVRO-2652: Fix Inconsistent Pretty Output Order
    
    Using json.dumps on a dict gives the simplest possible way to
    pretty-print a schema, but it doesn't give any control over the output
    order. But the test kit assumes the output is in a specific order, which
    is not guaranteed by older Python implementations. This change sorts the
    keys for the simplest possible stable output order.
    
    * AVRO-2652: Run Tests with Tox
    
    Tox enables testing with multiple versions of python in the same place.
    
    * AVRO-2652: Tox in Docker
    
    * AVRO-2657: Fix Python Interop Data Generator
    
    * AVRO-2657: Test with Interop Data
    
    * AVRO-2657: Make build.sh do interop tests
---
 lang/py/.gitignore                           |  2 ++
 lang/py/MANIFEST.in                          | 17 ++++++++++++++
 lang/py/avro/test/test_script.py             |  4 ++--
 lang/py/avro/test/test_tether_task_runner.py |  4 ++--
 lang/py/build.sh                             |  5 ++++-
 lang/py/scripts/avro                         |  2 +-
 lang/py/setup.cfg                            | 12 ++++++++--
 lang/py/setup.py                             |  6 ++---
 lang/py/tox.ini                              | 33 ++++++++++++++++++++++++++++
 share/docker/Dockerfile                      |  1 +
 10 files changed, 75 insertions(+), 11 deletions(-)

diff --git a/lang/py/.gitignore b/lang/py/.gitignore
index 2eaad89..4bd8e9d 100644
--- a/lang/py/.gitignore
+++ b/lang/py/.gitignore
@@ -9,3 +9,5 @@ avro/VERSION.txt
 avro/interop.avsc
 avro/tether/InputProtocol.avpr
 avro/tether/OutputProtocol.avpr
+.tox
+dist
diff --git a/lang/py/MANIFEST.in b/lang/py/MANIFEST.in
new file mode 100644
index 0000000..1378ab8
--- /dev/null
+++ b/lang/py/MANIFEST.in
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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
+#
+#     https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+include avro/*.avsc avro/tether/*.avpr 
+include avro/VERSION.txt avro/LICENSE avro/NOTICE
diff --git a/lang/py/avro/test/test_script.py b/lang/py/avro/test/test_script.py
index a92754f..db886d7 100644
--- a/lang/py/avro/test/test_script.py
+++ b/lang/py/avro/test/test_script.py
@@ -66,9 +66,9 @@ def looney_records():
 SCRIPT = join(dirname(dirname(dirname(__file__))), "scripts", "avro")
 
 _JSON_PRETTY = '''{
-    "type": "duck",
+    "first": "daffy",
     "last": "duck",
-    "first": "daffy"
+    "type": "duck"
 }'''
 
 def gen_avro(filename):
diff --git a/lang/py/avro/test/test_tether_task_runner.py b/lang/py/avro/test/test_tether_task_runner.py
index 8a79272..245f3bb 100644
--- a/lang/py/avro/test/test_tether_task_runner.py
+++ b/lang/py/avro/test/test_tether_task_runner.py
@@ -28,11 +28,11 @@ import time
 import unittest
 
 import avro.io
+import avro.test.mock_tether_parent
+import avro.test.word_count_task
 import avro.tether.tether_task
 import avro.tether.tether_task_runner
 import avro.tether.util
-import avro.test.mock_tether_parent
-import avro.test.word_count_task
 
 
 class TestTetherTaskRunner(unittest.TestCase):
diff --git a/lang/py/build.sh b/lang/py/build.sh
index 2dc6bd0..ff2c388 100755
--- a/lang/py/build.sh
+++ b/lang/py/build.sh
@@ -40,9 +40,12 @@ dist() {
 
 interop-data-generate() {
   ./setup.py generate_interop_data
+  cp -r avro/test/interop/data ../../build/interop
 }
 
 interop-data-test() {
+  mkdir -p avro/test/interop ../../build/interop/data
+  cp -r ../../build/interop/data avro/test/interop
   python -m unittest avro.test.test_datafile_interop
 }
 
@@ -51,7 +54,7 @@ lint() {
 }
 
 test_() {
-  ./setup.py test
+  tox
 }
 
 main() {
diff --git a/lang/py/scripts/avro b/lang/py/scripts/avro
index e0c116b..c9ed157 100755
--- a/lang/py/scripts/avro
+++ b/lang/py/scripts/avro
@@ -52,7 +52,7 @@ def print_json_pretty(row):
     """Pretty print JSON"""
     # Need to work around https://bugs.python.org/issue16333
     # where json.dumps leaves trailing spaces.
-    result = json.dumps(row, indent=4).replace(' \n', '\n')
+    result = json.dumps(row, sort_keys=True, indent=4).replace(' \n', '\n')
     print(result)
 
 _write_row = csv.writer(stdout).writerow
diff --git a/lang/py/setup.cfg b/lang/py/setup.cfg
index c1f9fc0..0c2148f 100644
--- a/lang/py/setup.cfg
+++ b/lang/py/setup.cfg
@@ -34,9 +34,14 @@ classifiers =
     Programming Language :: Python :: 2.7 :: Only
 
 [options]
-packages = avro
+packages =
+    avro
+    avro.test
+    avro.tether
 package_dir =
     avro = avro
+    avro.test = avro/test
+    avro.tether = avro/tether
 include_package_data = true
 setup_requires =
   isort
@@ -51,9 +56,12 @@ python_requires = <3.0,>=2.7
 avro =
     HandshakeRequest.avsc
     HandshakeResponse.avsc
-    share/VERSION.txt
+    VERSION.txt
     LICENSE
     NOTICE
+avro.tether =
+    InputProtocol.avpr
+    OutputProtocol.avpr
 
 [options.extras_require]
 snappy = python-snappy
diff --git a/lang/py/setup.py b/lang/py/setup.py
index fc662a3..43c97db 100755
--- a/lang/py/setup.py
+++ b/lang/py/setup.py
@@ -59,7 +59,7 @@ def _generate_package_data():
     # Create a PEP440 compliant version file.
     version_file_path = os.path.join(share_dir, _VERSION_FILE_NAME)
     with open(version_file_path, 'rb') as vin:
-        version = vin.read().replace('-', '+')
+        version = vin.read().replace(b'-', b'+')
     with open(os.path.join(_AVRO_DIR, _VERSION_FILE_NAME), 'wb') as vout:
         vout.write(version)
 
@@ -109,8 +109,8 @@ class GenerateInteropDataCommand(setuptools.Command):
 
 def _get_version():
   curdir = os.getcwd()
-  if os.path.isfile("share/VERSION.txt"):
-    version_file = "share/VERSION.txt"
+  if os.path.isfile("avro/VERSION.txt"):
+    version_file = "avro/VERSION.txt"
   else:
     index = curdir.index("lang/py")
     path = curdir[:index]
diff --git a/lang/py/tox.ini b/lang/py/tox.ini
new file mode 100644
index 0000000..dc3308e
--- /dev/null
+++ b/lang/py/tox.ini
@@ -0,0 +1,33 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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
+#
+#     https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+[tox]
+envlist =
+    py27
+
+[testenv]
+deps =
+    python-snappy
+    zstandard
+whitelist_externals =
+    cp
+    mkdir
+commands_pre =
+    mkdir -p avro/test/interop {toxinidir}/../../build/interop/data
+    cp -r {toxinidir}/../../build/interop/data avro/test/interop
+    python -m avro.test.gen_interop_data avro/interop.avsc avro/test/interop/data/py.avro
+    cp -r avro/test/interop/data {toxinidir}/../../build/interop
+commands =
+    python -m unittest discover
diff --git a/share/docker/Dockerfile b/share/docker/Dockerfile
index 669989e..2421882 100644
--- a/share/docker/Dockerfile
+++ b/share/docker/Dockerfile
@@ -64,6 +64,7 @@ RUN apt-get -qqy update \
                                                  ruby-dev \
                                                  source-highlight \
                                                  subversion \
+                                                 tox \
                                                  valgrind \
  && apt-get -qqy clean \
  && rm -rf /var/lib/apt/lists


Mime
View raw message