- changed title to More reliable and regular macOS testing
More reliable and regular macOS testing
I'd like to help run tests on macOS and perhaps get CI running on an external service. A good first step to help me is for someone to describe how to tests are currently run.
Comments (5)
-
reporter -
repo owner Hi Yaw,
Thanks again for helping me. I usually use tox to run all the tests with several interpreters. You may need to install those different Python versions. I will describe how to do that later on. Below you find what I had to do to run the unittests in Linux ubuntu-12-i386. Besides using Tox, one could also install savReaderWriter in a virtualenv and run
nosetests
there for the given Python version.For Mac, there might be problems with loading the SPSS I/O .dylib files (they live in
.\savReaderWriter\spssio\macos
). You may need to setDYLD_LIBRARY_PATH
orDYLD_FALLBACK_LIBRARY_PATH
. or perhaps useinstall_name_tool
, as described here: http://stackoverflow.com/questions/1937232/linking-to-a-dynamic-library-on-a-mac-with-full-pathRunning tests for all interpreters with Tox
# tox installation sudo apt-get update sudo apt-get install python-dev sudo pip install tox --upgrade # we need version 1.7.2 or higher # tox usage (first run takes a long time) tox --skip-missing-interpreters #tox -e py27 # run tests only for Python2.7 # tox output coverage-clean: commands succeeded py27: commands succeeded py33: commands succeeded SKIPPED: py34: InterpreterNotFound: python3.4 py35: commands succeeded SKIPPED: pypy: InterpreterNotFound: pypy docs: commands succeeded coverage: commands succeeded congratulations :)
Running tests 'manually' with nosetests in a virtualenv
[1] install savReaderWriter + dependencies in a virtualenv and run nosetests
sudo apt-get update sudo pip install virtualenv --upgrade virtualenv py27 source ~/py27/bin/activate cd ~/Downloads git clone https://bitbucket.org/fomcl/savreaderwriter.git --depth=1 cd savreaderwriter pip install -r dev-requirements.txt python setup.py install cd savReaderWriter nosetests deactivate
[2] if needed, build a python version (here 3.5) because the repository is not up-to-date (can't simply apt-get install it)
sudo apt-get install build-essential sudo apt-get install zlib1g zlib1g-dev libncurses5-dev libreadline6-dev ncurses-doc wget https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tar.xz tar -xvf Python-3.5.2.tar.xz cd Python-3.5.2/ ./config make make test sudo make altinstall
# [3] create a virtualenv that uses python3.5 as its interpreter, then run the tests as before.
cd ~ virtualenv -p $(which python3.5) py35 source ~/py35/bin/activate # ... then follow the 'git' and subsequent steps under [1]
Best wishes, Albert-Jan
-
reporter I ran the test manually with virtualenv for py27 and py35. Both versions three errors that have to do with locale.
The command I ran was:
`DYLD_FALLBACK_LIBRARY_PATH=/Users/yanokwa/Downloads/virtualenvs/savreaderwriter27/savReaderWriter/spssio/macos LC_ALL=en_US.UTF-8 nosetests;
The result I got was:
.F.S..................E.SS....ESSSSSSSSSSSSSSSSSSSSSS..E..S........................SSSSSSSS..........................................................................................................................S..SSSS......SS....... ====================================================================== ERROR: ioLocale is specified, which is required only if file encoding ---------------------------------------------------------------------- Traceback (most recent call last): File "/Users/yanokwa/Downloads/virtualenvs/savreaderwriter27/savReaderWriter/unit_tests/test_SavHeaderReader_ioLocale.py", line 42, in test_locale_correct ioLocale=self.ioLocale) as header: File "/Users/yanokwa/Downloads/virtualenvs/savreaderwriter27/savReaderWriter/savHeaderReader.py", line 55, in __init__ ioUtf8, ioLocale) File "/Users/yanokwa/Downloads/virtualenvs/savreaderwriter27/savReaderWriter/header.py", line 31, in __init__ super(Header, self).__init__(savFileName, ioUtf8, ioLocale) File "/Users/yanokwa/Downloads/virtualenvs/savreaderwriter27/savReaderWriter/generic.py", line 27, in __init__ locale.setlocale(locale.LC_ALL, "" if ioLocale is None else ioLocale) File "/Users/yanokwa/Downloads/virtualenvs/py27/lib/python2.7/locale.py", line 581, in setlocale return _setlocale(category, locale) Error: unsupported locale setting ====================================================================== ERROR: Failure: Error (unsupported locale setting) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Users/yanokwa/Downloads/virtualenvs/py27/lib/python2.7/site-packages/nose/loader.py", line 413, in loadTestsFromName addr.filename, addr.module) File "/Users/yanokwa/Downloads/virtualenvs/py27/lib/python2.7/site-packages/nose/importer.py", line 47, in importFromPath return self.importFromDir(dir_path, fqname) File "/Users/yanokwa/Downloads/virtualenvs/py27/lib/python2.7/site-packages/nose/importer.py", line 94, in importFromDir mod = load_module(part_fqname, fh, filename, desc) File "/Users/yanokwa/Downloads/virtualenvs/savreaderwriter27/savReaderWriter/unit_tests/test_SavHeaderReader_metadata_roundtrip_ioUtf8.py", line 34, in <module> with sav.SavReader(in_savFileName, rawMode=True, **b_settings) as data: File "/Users/yanokwa/Downloads/virtualenvs/savreaderwriter27/savReaderWriter/savReader.py", line 95, in __init__ ioUtf8, ioLocale) File "/Users/yanokwa/Downloads/virtualenvs/savreaderwriter27/savReaderWriter/header.py", line 31, in __init__ super(Header, self).__init__(savFileName, ioUtf8, ioLocale) File "/Users/yanokwa/Downloads/virtualenvs/savreaderwriter27/savReaderWriter/generic.py", line 27, in __init__ locale.setlocale(locale.LC_ALL, "" if ioLocale is None else ioLocale) File "/Users/yanokwa/Downloads/virtualenvs/py27/lib/python2.7/locale.py", line 581, in setlocale return _setlocale(category, locale) Error: unsupported locale setting ====================================================================== ERROR: test_date_conversion (savReaderWriter.unit_tests.test_SavReader_decodeSPSSDate.test_SavReader_decode_SPSSDate) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Users/yanokwa/Downloads/virtualenvs/savreaderwriter27/savReaderWriter/unit_tests/test_SavReader_decodeSPSSDate.py", line 19, in test_date_conversion ioLocale="C.UTF-8") as writer: File "/Users/yanokwa/Downloads/virtualenvs/savreaderwriter27/savReaderWriter/savWriter.py", line 191, in __init__ super(Header, self).__init__(savFileName, ioUtf8, ioLocale) File "/Users/yanokwa/Downloads/virtualenvs/savreaderwriter27/savReaderWriter/generic.py", line 27, in __init__ locale.setlocale(locale.LC_ALL, "" if ioLocale is None else ioLocale) File "/Users/yanokwa/Downloads/virtualenvs/py27/lib/python2.7/locale.py", line 581, in setlocale return _setlocale(category, locale) Error: unsupported locale setting ====================================================================== FAIL: savReaderWriter.unit_tests.test_Generic.test_missingValuesLowHigh ---------------------------------------------------------------------- Traceback (most recent call last): File "/Users/yanokwa/Downloads/virtualenvs/py27/lib/python2.7/site-packages/nose/case.py", line 197, in runTest self.test(*self.arg) File "/Users/yanokwa/Downloads/virtualenvs/savreaderwriter27/savReaderWriter/unit_tests/test_Generic.py", line 18, in test_missingValuesLowHigh assert desired == actual AssertionError ---------------------------------------------------------------------- Ran 235 tests in 1.724s FAILED (SKIP=41, errors=3, failures=1)
Have you considered using TravisCI or CircleCI to run these tests? Both have Mac OS X environments and are free for open source. The catch is that you have to use Github (or sync your Bitbucket repo to Github).
-
repo owner Hi,
Thanks a lot for running the tests! The first two tests depend on the presence of a locale
de_DE.cp1252
(a German unix locale, but with a Windows codepage). I had tolocaledef
this locale on my Linux machine. I could skip this test in the likely event that this locale is not present on the user's computer. The date decode test errors because Mac, apparently, does not have a localeC.UTF-8
. Do you know what's the name of the C locale on Mac OS? I get this output on my Linux machine:albertjan@debian:~$ locale -a | grep ^C C C.UTF-8 albertjan@debian:~$ locale LANG=en_US.UTF-8 LANGUAGE= LC_CTYPE="en_US.UTF-8" LC_NUMERIC="en_US.UTF-8" LC_TIME="en_US.UTF-8" LC_COLLATE="en_US.UTF-8" LC_MONETARY="en_US.UTF-8" LC_MESSAGES="en_US.UTF-8" LC_PAPER="en_US.UTF-8" LC_NAME="en_US.UTF-8" LC_ADDRESS="en_US.UTF-8" LC_TELEPHONE="en_US.UTF-8" LC_MEASUREMENT="en_US.UTF-8" LC_IDENTIFICATION="en_US.UTF-8" LC_ALL=
Thanks for the tip about Circle CI, I did not know that one. Yes, Bitbucket integration with CIs is not nearly as good as with Github. I was hoping the situation would gradually improve. I did in fact set up a Github mirror before, but I abandoned it. I want it to be as hassle-free as possible, like what I have with Appveyor CI. It should be possible, though, to automatically push to two remotes in one go. Circle CI appears to have limited free access to Mac OS (https://circleci.com/pricing/#faq-section-os-x). AND it is available for Bitbucket (https://circleci.com/integrations/bitbucket/). So I willl try that!
Best wishes, Albert-Jan
-
reporter Here's what I'm getting on macOS Sierra
$ locale -a ... de_DE de_DE.ISO8859-1 de_DE.ISO8859-15 de_DE.UTF-8 ... en_US en_US.ISO8859-1 en_US.ISO8859-15 en_US.US-ASCII en_US.UTF-8 ... C POSIX
And of the variables you displayed, the only non-empty one is
$ echo $LANG en_US.UTF-8
Looking forward to the CircleCI integration!
- Log in to comment