TA-Lib / ta-lib-python

Python wrapper for TA-Lib (http://ta-lib.org/).
http://ta-lib.github.io/ta-lib-python
Other
9.56k stars 1.75k forks source link

Extract tests to their own directory #591

Closed xmatthias closed 1 year ago

xmatthias commented 1 year ago

This is mostly (actually exclusively) the work of @Tktech in #500. It's simply extracting the test refactoring part - which will simplify review and hopefully merging.

I've also removed the duplicate installation of regular requirements - which are included in requirements_test.txt already.

mrjbq7 commented 1 year ago

Remind me what the point of this PR is? (Not being critical, just confused)

xmatthias commented 1 year ago

i realize my description was a bit ... rushed - sorry for that.

call it technical maintenance / improving the code structure and tests.

Tests shouldn't be mixed in with regular code - and most/all python guides about project structuring i've seen use a dedicated tests directory, to have clear separation between functional code - and test code. (some newer ones also user a src directory for regular code - but i don't think that's necessary).

The location the tests are currently in (mixed in along with the code, within the talib directory) means that they're included in the release (in the tarball that's uploaded to pypi).

If you install ta-lib from pypi and look at the installation directory (e.g. env/lib/python3.10/site-packages/talib/) - you'll find the following:

-rw-r--r-- 1 xmatt xmatt     799 Nov 24 19:26 abstract.py
-rw-r--r-- 1 xmatt xmatt     105 Nov 24 19:26 deprecated.py
-rw-r--r-- 1 xmatt xmatt    8879 Nov 24 19:26 __init__.py
drwxr-xr-x 2 xmatt xmatt    4096 Nov 24 19:26 __pycache__
-rw-r--r-- 1 xmatt xmatt     186 Nov 24 19:26 stream.py
-rwxr-xr-x 1 xmatt xmatt 6606568 Nov 24 19:26 _ta_lib.cpython-310-x86_64-linux-gnu.so
-rw-r--r-- 1 xmatt xmatt   12992 Nov 24 19:26 test_abstract.py
-rw-r--r-- 1 xmatt xmatt   16203 Nov 24 19:26 test_data.py
-rw-r--r-- 1 xmatt xmatt    7149 Nov 24 19:26 test_func.py
-rw-r--r-- 1 xmatt xmatt    2327 Nov 24 19:26 test_pandas.py
-rw-r--r-- 1 xmatt xmatt    3074 Nov 24 19:26 test_polars.py
-rw-r--r-- 1 xmatt xmatt    2503 Nov 24 19:26 test_stream.py

The test files are unnecessary (this is installed from a release). running pytest on this directory is not really possible - or rather, not how it's designed to work).

500 did see little progress, and personally, i know from experience how difficult it is to review a huge PR.

i therefore think it's beneficial to improve ta-lib incrementally in small, managable/reviewable PR's (but the goal should still be to have wheels available automatically/semiautomatically).

mrjbq7 commented 1 year ago

okay, merged.

I do want to get the cibuildwheel PR working, but I'm unsure how to test the PyPI upload feature.