73 Commits

Author SHA1 Message Date
Dave Jones
c820636fcb Fix #279 once and for all (ha! ;)
This implements the proposal discussed in the re-opened #279 to add a
pin_factory argument at the device level and remove the ability to
specify a pin instance to device constructors (they now only accept a
pin specification).

Note: there's still a couple of bits to tidy up (tests on "real" Pis,
and pin_factory.release_all needs refinement) but the test suite is now
at least capable of passing on a PC.
2017-07-04 00:26:41 +01:00
Dave Jones
56f2152daf Change CompositeDevice to reject invalid identifiers
Also updated StatusBoard and StatusZero to reject duplicate identifiers
(namedtuple doesn't pick 'em up because they're passed in a dict and
thus the dups are squashed prior to the call). Added tests for all the
relevant stuff.
2017-06-25 20:44:13 +01:00
Dave Jones
c9857d55ce Fix statusboard tests
No point testing for invalid names (as they're not *really* invalid);
also ensure tests requiring PWM using MockPWMPin
2017-06-23 23:02:58 +01:00
Ben Nuttall
83cf4cada5 Add tests for StatusZero and StatusBoard 2017-06-23 22:59:29 +01:00
Dave Jones
ef554d896d Fix tests for pinout 2017-06-23 19:02:03 +01:00
Dave Jones
a99e0746c3 Fix #279
Permit replacement of pin_factory without closing old factory. However,
continue closing devices associated with extant pin factory at script
termination.
2017-06-22 22:45:00 +01:00
Dave Jones
d2a7c1434a Fix SPI tests when spidev is installed
Doh! SPI tests fail when the spidev package is installed (which it
normally isn't in my virtualenv) because hardware SPI always takes
precedence and the mock SPI stuff only replaces software SPI.
2017-06-21 14:40:52 +01:00
Dave Jones
35f1ff0623 Eliminate compatibility names from tests
No need to run the same tests on the same backends
2017-06-21 14:40:30 +01:00
Dave Jones
5487124f74 Fix pigpiod SPI conflicts
Wrong classname in the software implementation and for some reason I'd
reverted a change on spi_flags somewhere... Also removed the clause
skipping remote pigpiod tests

Tested this commit with hardware and software SPI remotely - working
nicely
2017-06-16 13:28:55 +01:00
Dave Jones
e5336c38ce Run all tests on all platforms
Also renamed GPIOZERO_INPUT_PIN to GPIOZERO_TEST_INPUT_PIN, and fixed up
the pigpio factory so it actually raises an exception if the connection
fails and we don't try and control the daemon anymore.
2017-06-16 13:28:55 +01:00
Dave Jones
945bea4e54 Added keyword args to MockFactory.pin
And a few other last minute fixes
2017-06-16 13:28:55 +01:00
Dave Jones
2ecc25f995 Enable all the factory tests
Ooops ...
2017-06-16 13:28:55 +01:00
Dave Jones
2495939603 Fix real pin tests ... and some other bits
The real pin tests were broken by the new factory stuff. This commit
fixes them up, and fixes up a few other bits besides (like why the
pigpio PWM tests were failing, why RPi.GPIO sometimes segfaulted on PWM
tests, etc.)

It also causes the real pin tests to run against MockPin (thanks to
@lurch for the suggestion!). This required some tweaks to MockPin to
make it emulate physically pulled up pins itself (which in turn
necessitated changing quite a few pin numbers in the main test suite
because we were using 2 and 3 everywhere), and to allow one MockPin to
drive another. Anyway, everything's working now including all the tests
on a Pi (haven't tried RPIO yet, but only because I'm on a Pi3 -
everything else works with overall coverage of 88% :).
2017-06-16 13:28:55 +01:00
Dave Jones
4049ef5094 Work around for longer object lifetimes on pypy
On pypy the subordinate LED objects in RGBLED composite objects do die
on failed construction ... eventually. Unfortunately it's not quick
enough to prevent the following tests from failing. As we can't know for
certain exactly which test is going to follow, it's best to simply clear
down the reservation table before each test.
2017-06-16 13:28:55 +01:00
Dave Jones
15d2c860d3 Use with in a few more tests 2017-06-16 13:28:55 +01:00
Dave Jones
ce6217c14f Fix #459 - properly support remote SPI with pigpio
Sorry! Dave's messing around with the pin implementations again.
Hopefully the last time. The pin_factory is now really a factory object
which can be asked to produce individual pins or pin-based interfaces
like SPI (which can be supported properly via pigpio).
2017-06-16 13:28:55 +01:00
Dave Jones
b7aa7e8506 Fix up pinout tests so they work with new structure 2017-06-13 16:23:27 +01:00
Andrew Scheller
fc54667f34 More small tidyups
- switch to using sys.exit instead of exit
 - always exit with error-code 1
 - don't bother testing error-codes
 - documentation wording tweak
2016-12-18 03:33:50 +00:00
Ben Nuttall
117e4f5972 Use from to import rather than rename 2016-12-06 13:39:16 +00:00
Ben Nuttall
6e6c80a9fa Merge branch 'master' of https://github.com/stewartadcock/python-gpiozero into stewartadcock-master 2016-12-05 20:56:25 +00:00
Stewart
48d7924395 Fix import in tests 2016-11-07 22:46:46 +00:00
Stewart
726e861238 Add pinout command-line tool 2016-11-07 22:09:59 +00:00
Andrew Scheller
9fbed050ce Add a new alternating_values SourceTool 2016-09-21 16:16:42 +01:00
Dave Jones
9046ea3033 Fix #436
Permit partial, partialmethod, and wraps to be used with event handlers
2016-09-20 11:16:04 +01:00
Ben Nuttall
a79f8ccc16 Merge pull request #446 from lurch/traffic_lights_tweak
Add extra TrafficLight tests, and remove the redundant setattr function
2016-09-19 14:13:51 +01:00
Andrew Scheller
1b3e6a429b Add extra TrafficLight tests, and remove the redundant setattr function
- `CompositeDevice`s can't have any of their attributes set anyway
2016-09-19 12:00:38 +01:00
Andrew Scheller
c35741c793 Add support for the Pi-Stop Traffic-light board 2016-09-19 01:11:29 +01:00
Dave Jones
27c0703043 Fix #354
Actually, "fix" doesn't really do this justice. This is closer to "nukes
from orbit" ...
2016-09-13 17:37:17 +01:00
Dave Jones
737a739cd6 Fix #421
Added SPI tests, simplified the shared SPI software bus implementation,
and fixed several protocol errors in our MCP3xxx classes (the x2 and x1
protocols were wrong)
2016-09-08 22:24:06 +01:00
Dave Jones
02f7d20bc3 Fix #248
Add Servo and AngularServo implementation along with docs and tests.
This is a deliberately minimal implementation designed to be added to as
we agree on new extensions (better than making an all-singing,
all-dancing version in which I get things wrong and then wind up making
backward incompatible changes to get it right :)
2016-08-30 21:33:28 +01:00
Dave Jones
6cc308e44a Fix #354, fix #389
Overhaul the pi_info system:

Pin factories are now capable of generating pi_info themselves (although
currently they all just look up the revision and call pi_info with a
specific one).

PiGPIOPin will now return pi_info for the remote pi which can be
specified by parameter or implicitly by the environment vars.

Overvolted Pis should work properly no matter what (some argument over
whether the revision 7 or 8 chars in this case; both should work). Added
some minor tweaks for the new camera-capable Pi Zero

Finally, added a bunch of tests for pins.data
2016-08-29 11:48:23 +01:00
Andrew Scheller
f96ab609e2 TrafficLights.value also reports 'yellow' instead of 'amber' when appropriate 2016-06-10 12:44:39 +01:00
Andrew Scheller
38262a125f Add 'yellow' as an alias of 'amber' for TrafficLights
Fixes #345
2016-06-10 12:43:22 +01:00
Andrew Scheller
4e58e25bca Revert "Tweak RGBLED tests - increases coverage" 2016-06-10 12:32:37 +01:00
Andrew Scheller
7987f5a786 Tweak RGBLED tests - increases coverage 2016-06-10 12:23:13 +01:00
Andrew Scheller
b3035d306e Add value-setter for Robot class
Fixes #305
2016-05-28 13:50:47 +01:00
Andrew Scheller
e832cfeb23 Add extra init-method params
adds `initial_value` to PiLiter, TrafficLights, PiTraffic & SnowPi and
adds `pwm` to PiTraffic
2016-05-28 12:17:52 +01:00
Andrew Scheller
3a7acbf89d Add LedBorg as a subclass of RGBLED 2016-05-26 20:27:16 +01:00
Dave Jones
92cb735c7f Merge pull request #319 from lurch/test_ledcollection_active_high
Add tests for LEDBoard.active_high and LEDBarGraph.active_high
2016-05-11 16:15:58 +01:00
Andrew Scheller
87d00f9047 Replace Event.wait(0) with Event.is_set()
The functionality is identical, and IMHO the latter is much more readable
2016-05-10 15:03:28 +01:00
Andrew Scheller
eaf0d5ce1e Add tests for LEDBoard.active_high and LEDBarGraph.active_high
Also add LEDBoard.value tests
2016-05-10 11:53:36 +01:00
Dave Jones
c44a4bfe4b Merge pull request #303 from lurch/non_pwmed_motor
Add a `pwm` option to the RGBLED and Motor constructors
2016-05-09 11:52:47 +01:00
Dave Jones
afcec87bab Merge pull request #318 from waveform80/fix-codecov-changes
Mark optional sleeps with no coverage
2016-05-09 11:17:27 +01:00
Dave Jones
fd4075835e Mark optional sleeps with no coverage
Codecov frequently whinges about "unexpected coverage changes" on PRs;
this is because the sleep lines affected sometimes execute and sometimes
don't (they're only there to ensure something exists before we test it).
Hopefully codecov notices the pragmas...
2016-05-09 11:10:31 +01:00
Andrew Scheller
0c2a13367d Tweak test for better coverage report 2016-05-09 00:18:10 +01:00
Andrew Scheller
c9461c50d3 Add a pwm option to the RGBLED and Motor constructors
...along with the other necessary changes required, to allow them to
optionally be used with non-PWM-capable pins
2016-05-08 18:23:30 +01:00
Dave Jones
1575863ba5 Merge pull request #312 from lurch/rgbled_pulse
Add RGBLED.pulse method
2016-05-08 11:53:14 +01:00
Dave Jones
afc847c159 Merge pull request #307 from lurch/extra_board_tests
Add more unit tests, fix a few small bugs
2016-05-08 11:36:27 +01:00
Dave Jones
4d8e49c5b8 Merge pull request #304 from lurch/patch-2
Minor Energenie tweaks
2016-05-08 11:10:38 +01:00
Andrew Scheller
18bb3f559e Add RGBLED.pulse method
Also add timing tests to all the blink unit-tests
2016-05-04 11:14:36 +01:00