kivy-ios/tests/test_libs/main.py
Richard Larkin 64bd692632
Flake8 CI fixes (#451)
* Pep8 fixes

* tox Pep8 compliance

* Excluded external tools folder from flake 8 tests

* Added Flake 8 exclusions

* Pep8 fixes

* Pep8 fixes

* Corrected type

* Pep8 fixes

* Pep 8 compliance

* Pep8 fixes

* Pep8  fixes

* Pep8 fixes

* Pep8 fixes

* Pep 8 fixes

* Pep 8 fixes

* Pep8 fixes

* Pep8 fixes

* Pep8 fixes

* Pep8

* Pep8

* Pep 8

* Pep 8

* Pep8 fixes

* Pep8

* Pep8

* Pep8

* Pep8 fixes

* Pep8 fixes

* Pep8 fixes

* Pep8 fixes

* Pep8 fixes

* Revert chagnes

* Revert changes to kivy/__init.py

* Revert changes

* REvert changes

* Revert changes

* Revert changes to toolchain

* Add files exclusions to tox.ini

* Added exclusions for alias recipes

* Remove dead code

* Added py extension to recipes

* Removed recipe build skip

* Improves recipe matching

Previous expression was matching all the following three lines of a `git diff --name-only` output.
```
recipes/hostlibffi/__init__.py
recipes/hostpython.py
recipes/hostpython2/__init__.py
```
This was resulting to a bug when later splitting with `recipe = file_path.split('/')[1]` the `recipes/hostpython.py` string would return including the `\n` new line char, see:
 ```
>>> 'recipes/hostpython.py\n'.split('/')[1]
'hostpython.py\n'
>>> 'recipes/hostlibffi/__init__.py\n'.split('/')[1]
'hostlibffi'
>>> 
```

Co-authored-by: Andre Miras <AndreMiras@users.noreply.github.com>
2020-04-25 18:28:16 +02:00

78 lines
1.7 KiB
Python

import traceback
from time import sleep
FAILED = []
SUCCESS = []
def test_kivy():
import kivy
import kivy.event
import kivy.core.window
import kivy.uix.widget # noqa: F401
def test_audiostream():
from audiostream import get_output
from audiostream.sources.wave import SineSource
stream = get_output(channels=2, rate=22050, buffersize=128)
source = SineSource(stream, 220)
source.start()
sleep(.5)
source.stop()
def test_numpy():
print("NPY: test import numpy")
import numpy as np
print("NPY: basic calculation")
print(np.ones(10) * np.sin(2))
print("NPY: access to random module")
print(np.random.mtrand.beta(1, 2))
print("NPY: access to fft")
print(np.fft.fft(np.exp(2j * np.pi * np.arange(8) / 8)))
print("NPY: access to linalg")
from numpy import linalg as LA
a = np.array([[1., 2.], [3., 4.]])
ainv = LA.inv(a)
print(np.allclose(np.dot(a, ainv), np.eye(2)))
def test_curly():
import curly # noqa: F401
def run_test(f, name):
# run a single test
print("=> Run", name)
try:
f()
SUCCESS.append(name)
except Exception:
print("!! Failed", name)
traceback.print_exc()
FAILED.append(name)
def run():
# auto find test and run
for key in globals():
if not key.startswith("test_"):
continue
print("FOUND", key)
func = globals()[key]
run_test(func, key)
# print summary
print("")
print("=== [ LIBS SUMMARY ] ===")
print("")
print("{}/{} tests".format(
len(SUCCESS),
len(SUCCESS) + len(FAILED)
))
print("Success: ", ", ".join(SUCCESS))
print("Failed: ", ", ".join(FAILED))
if __name__ == "__main__":
run()