## Motivation I want to add style (static code analysis) test and pytest for the python code. When I did debug the python code for the issue related to library path: https://github.com/rpm-software-management/rpm/issues/130 , I thought adding those was useful.
## Detail We have tests/rpmpython.at for the rpm python binding. However I think that using pytest is also good to maintain and customize the detail of the test easily. The style check for python code is one of the merit to keep the python code clean. - Style check by `flake8`. - I used `flake8` because `flake8` is better than pylint simple style check. and it is also used in `rpmlint` project. - I used `python/.flake8` as a compromise to warnings from "import *". In the future, we can do below style removing the `.flake8` file. > http://docs.python-guide.org/en/latest/writing/structure/#modules > import modu > [...] > x = modu.sqrt(4) # sqrt is visibly part of modu's namespace - Test for python binding by pytest. The test is here `python/tests/test_rpm.py`. Right now only 1 test case as a proposal. - python/setup.py.in In the tox test, `pytyhon setup.py build` is run under `/tmp/pip-l2s21mdp-build`. So, previous logic to check parent directory's `Makefile.am` file does not work in this case. In the case of that there is no parent directory for build directory, users can build with specifying include and library direcotory. ``` RPM_NO_SEARCH_BUILD_DIR=1 python3 setup.py build \ --include-dirs=/path/to/include/ --library-dirs=/path/to/libs/ ``` - ci/Dockerfile Added the logic to run the pytest and the style test. ## Workflow example ### Build ``` $ ./autogen.sh --noconfigure $ ./configure --prefix="$(pwd)/dest" $ make ``` ### Tox test and build for the python module. ``` $ cd python $ tox $ python setup.py build $ python3 setup.py build $ cd .. ``` ### Install ``` $ make install ``` ### Check linked libraries. ``` $ LD_LIBRARY_PATH="$(pwd)/dest/lib" \ ldd python/build/lib.*/rpm/*.so python/build/lib.linux-x86_64-2.7/rpm/_rpmb.so: linux-vdso.so.1 (0x00007ffdd5e68000) librpm.so.8 => /home/jaruga/git/rpm/dest/lib/librpm.so.8 (0x00007f6681393000) librpmio.so.8 => /home/jaruga/git/rpm/dest/lib/librpmio.so.8 (0x00007f6681164000) librpmbuild.so.8 => /home/jaruga/git/rpm/dest/lib/librpmbuild.so.8 (0x00007f6680f3a000) ... ``` See https://gist.github.com/junaruga/789866509a21afb32e3c1ab40b48120a to check full result of the `ldd` command. You can view, comment on, or merge this pull request online at: https://github.com/rpm-software-management/rpm/pull/303 -- Commit Summary -- * Add pytest and style environment for rpm python bindings module. -- File Changes -- M ci/Dockerfile (14) A python/.flake8 (5) M python/.gitignore (1) M python/rpm/__init__.py (4) M python/setup.py.in (76) A python/test-requirements.txt (2) A python/tests/test_rpm.py (6) A python/tox.ini (19) -- Patch Links -- https://github.com/rpm-software-management/rpm/pull/303.patch https://github.com/rpm-software-management/rpm/pull/303.diff -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/rpm-software-management/rpm/pull/303
_______________________________________________ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint