From d12cc0ac80b4e4521874856429aa14ab00a2a73a Mon Sep 17 00:00:00 2001 From: IvanHrasko Date: Wed, 8 Jul 2015 12:25:03 +0200 Subject: [PATCH 1/4] ihrasko: open stdout and stderr in text mode and avoid type errors in Python 3 during tests --- test/test.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/test/test.py b/test/test.py index 0258c3a..1399995 100644 --- a/test/test.py +++ b/test/test.py @@ -46,9 +46,22 @@ def fetch_url(src, dst): def exe(command): + """ + Executes command and returns string representations of stdout and stderr captured from the console. + When universal_newlines=True stdout and stderr are opened in text mode. + Otherwise, they are opened in binary mode. In that case captured stdout and stderr + are not strings and Python 3 throws type error when compared against strings later in tests. + + Note: + This feature is only available if Python is built with universal newline support (the default). + Also, the newlines attribute of the file objects stdout, stdin and stderr are not updated by the + communicate() method. + See https://docs.python.org/2/library/subprocess.html + """ stdout, stderr = subprocess.Popen(shlex.split(command), stdout=subprocess.PIPE, - stderr=subprocess.PIPE).communicate() + stderr=subprocess.PIPE, + universal_newlines=True).communicate() return stdout, stderr # ------------------------------------------------------------------------------ From 07c8ccdbc798d0e139e5af212b7744be17313634 Mon Sep 17 00:00:00 2001 From: IvanHrasko Date: Wed, 8 Jul 2015 12:32:11 +0200 Subject: [PATCH 2/4] ihrasko: add testing with Python 3.4 at AppVeyor --- appveyor.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 9c28186..df1de58 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -5,9 +5,9 @@ # OS: 64-bit Windows Server 2012 R2 # Compilers: 64-bit MinGw-w64 5.1.0 (downloaded during script execution) # Python: 2.7, both 32-bit and 64-bit versions +# Python: 3.4, both 32-bit and 64-bit versions # # Notes: -# Can be extended for use with Python 3 # Where "ps:" is used commands are executed in PowerShell ## @@ -21,12 +21,17 @@ environment: # set MinGw-w64 (64-bit) version 5.1.0 download URL url: http://kent.dl.sourceforge.net/project/mingw-w64/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/5.1.0/threads-posix/seh/x86_64-5.1.0-release-posix-seh-rt_v4-rev0.7z # user can possibly use different Python versions, we try to test multiple cases -# 64-bit version is recommended +# 64-bit version on 64-bit system allows easier installation of Python packages using .exe installers +# and better CMake automatic detection of some Python tools matrix: # Python 2.7; 32-bit version - python: C:\Python27;C:\Python27\Scripts # Python 2.7; 64-bit version - python: C:\Python27-x64;C:\Python27-x64\Scripts +# Python 3.4; 32-bit version + - python: C:\Python34;C:\Python34\Scripts +# Python 3.4; 64-bit version + - python: C:\Python34-x64;C:\Python34-x64\Scripts build_script: # add location of used Python to path From 7cc29aa33bef5cbb0317d001eb2d991f715be25d Mon Sep 17 00:00:00 2001 From: IvanHrasko Date: Wed, 8 Jul 2015 12:50:21 +0200 Subject: [PATCH 3/4] ihrasko: use variable instead of hardcoded path --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index df1de58..9532664 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -55,7 +55,7 @@ build_script: - pip install pytest # go back to project source dir -- cd C:\projects\autocmake +- cd %APPVEYOR_BUILD_FOLDER% test_script: # show environment From a286f5a8142d727b86c34725fc003edaa3cef08a Mon Sep 17 00:00:00 2001 From: IvanHrasko Date: Wed, 8 Jul 2015 13:46:06 +0200 Subject: [PATCH 4/4] ihrasko: fix pep8 style --- test/test.py | 1 - 1 file changed, 1 deletion(-) diff --git a/test/test.py b/test/test.py index 1399995..eb91051 100644 --- a/test/test.py +++ b/test/test.py @@ -51,7 +51,6 @@ def exe(command): When universal_newlines=True stdout and stderr are opened in text mode. Otherwise, they are opened in binary mode. In that case captured stdout and stderr are not strings and Python 3 throws type error when compared against strings later in tests. - Note: This feature is only available if Python is built with universal newline support (the default). Also, the newlines attribute of the file objects stdout, stdin and stderr are not updated by the