Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
updates to the pytest tests to fix the issues with pwm, added 2 new t…
…ests that bring in 5 total unit tests. python3 unit tests are passing, this will close #42 and close #47
- Loading branch information
1 parent
f7bec3f
commit 29377cf
Showing
18 changed files
with
149 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,60 @@ | ||
# PyPi Packaging | ||
package: clean | ||
@echo " ** PACKAGING FOR PYPI **" | ||
python setup.py sdist | ||
|
||
# PyPi Publishing | ||
publish: package | ||
@echo " ** UPLOADING TO PYPI **" | ||
twine upload dist/* | ||
|
||
# Clean all the things | ||
clean: | ||
@echo " ** CLEANING CHIP_IO **" | ||
rm -rf CHIP_IO.* build dist | ||
rm -f *.pyo *.pyc | ||
rm -f *.egg | ||
rm -rf __pycache__ | ||
rm -rf debian/python-chip-io* | ||
rm -rf debian/python3-chip-io* | ||
|
||
tests: | ||
py.test | ||
# Run all the tests | ||
tests: pytest2 pytest3 | ||
|
||
# Run the tests with Python 2 | ||
pytest2: | ||
@echo " ** RUNING CHIP_IO TESTS UNDER PYTHON 2 **" | ||
pushd test; python -m pytest; popd | ||
|
||
# Run the tests with Python 3 | ||
pytest3: | ||
@echo " ** RUNING CHIP_IO TESTS UNDER PYTHON 3 **" | ||
pushd test; python3 -m pytest; popd | ||
|
||
# Build all the things | ||
build: | ||
@echo " ** BUILDING CHIP_IO: PYTHON 2 **" | ||
python setup.py build --force | ||
|
||
# Install all the things | ||
install: build | ||
@echo " ** INSTALLING CHIP_IO: PYTHON 2 **" | ||
python setup.py install --force | ||
|
||
# Build for Python 3 | ||
build3: | ||
@echo " ** BUILDING CHIP_IO: PYTHON 3 **" | ||
python3 setup.py build --force | ||
|
||
# Install for Python 3 | ||
install3: build3 | ||
@echo " ** INSTALLING CHIP_IO: PYTHON 3 **" | ||
python3 setup.py install --force | ||
|
||
# Install for both Python 2 and 3 | ||
all: install install3 | ||
|
||
# Create a deb file | ||
debfile: | ||
@echo " ** BUILDING DEBIAN PACKAGES **" | ||
dpkg-buildpackage -rfakeroot -uc -b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
python-chip-io_0.4.0-1_armhf.deb python optional | ||
python3-chip-io_0.4.0-1_armhf.deb python optional | ||
python-chip-io_0.5.3-1_armhf.deb python optional | ||
python3-chip-io_0.5.3-1_armhf.deb python optional |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/usr/bin/python | ||
|
||
import CHIP_IO.SOFTPWM as PWM | ||
import CHIP_IO.GPIO as GPIO | ||
import CHIP_IO.OverlayManager as OM | ||
import time | ||
import datetime | ||
|
||
if __name__ == "__main__": | ||
# SETUP VARIABLES | ||
PWMGPIO = "XIO-P7" | ||
#PWMGPIO = "LCD-D4" | ||
COUNT = 150 | ||
SLEEPTIME = 0.01 | ||
|
||
time.sleep(1) | ||
|
||
# SETUP PWM | ||
try: | ||
print("PWM START") | ||
#PWM.toggle_debug() | ||
PWM.start(PWMGPIO, 50, 45, 1) | ||
|
||
# UNCOMMENT FOR CRASH | ||
print("PWM SET FREQUENCY") | ||
PWM.set_frequency(PWMGPIO, 10) | ||
|
||
# UNCOMMENT FOR CRASH | ||
print("PWM SET DUTY CYCLE") | ||
PWM.set_duty_cycle(PWMGPIO, 25) | ||
|
||
#time.sleep(COUNT*SLEEPTIME + 1) | ||
raw_input("PRESS ENTER WHEN DONE") | ||
|
||
except: | ||
raise | ||
finally: | ||
# CLEANUP | ||
print("CLEANUP") | ||
PWM.stop(PWMGPIO) | ||
PWM.cleanup() | ||
#OM.unload("PWM0") | ||
#GPIO.cleanup() | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import pytest | ||
|
||
import CHIP_IO.LRADC as LRADC | ||
|
||
class TestLRADC: | ||
def test_scale_factor(self): | ||
assert LRADC.get_scale_factor() == 31.25 | ||
|
||
def test_sample_rate_values(self): | ||
assert LRADC.get_allowable_sample_rates() == (32.25, 62.5, 125, 250) | ||
|
||
def test_set_sample_rate(self): | ||
LRADC.set_sample_rate(32.25) | ||
assert LRADC.get_sample_rate() == 32.25 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import pytest | ||
|
||
import CHIP_IO.Utilities as UT | ||
|
||
class TestUtilities: | ||
def test_invalid_set_1v8_with_string(self): | ||
assert not UT.set_1v8_pin_voltage("yaystring") | ||
|
||
def test_invalid_set_1v8_with_outofbounds_value(self): | ||
assert not UT.set_1v8_pin_voltage(0.5) | ||
assert not UT.set_1v8_pin_voltage(4.5) |