Browse Source

Simplified testing packages

master^2
Cefn Hoile 3 years ago
parent
commit
38566e3a72
13 changed files with 16 additions and 43 deletions
  1. +2
    -2
      test/src/testing/__init__.py
  2. +14
    -1
      test/src/testing/adafruit_blinka.py
  3. +0
    -0
      test/src/testing/implementation/all/__init__.py
  4. +0
    -0
      test/src/testing/implementation/circuitpython/__init__.py
  5. +0
    -0
      test/src/testing/implementation/circuitpython/digitalio.py
  6. +0
    -8
      test/src/testing/implementation/micropython/__init__.py
  7. +0
    -21
      test/src/testing/implementation/micropython/digitalio.py
  8. +0
    -11
      test/src/testing/profiling/__init__.py
  9. +0
    -0
      test/src/testing/universal/__init__.py
  10. +0
    -0
      test/src/testing/universal/digitalio.py
  11. +0
    -0
      test/src/testing/universal/i2c.py
  12. +0
    -0
      test/src/testing/universal/microcontroller.py
  13. +0
    -0
      test/src/testing/universal/uart.py

+ 2
- 2
test/src/testing/__init__.py View File

@ -91,12 +91,12 @@ def test_prepare(casetype):
def main():
"""
moduleNames = ["testing.implementation.all.digitalio",]
moduleNames = ["testing.implementation.universal.digitalio",]
if agnostic.implementation == "micropython":
moduleNames.extend([ "testing.implementation.micropython.digitalio",])
"""
moduleNames = ["testing.implementation.all.bitbangio"]
moduleNames = ["testing.implementation.universal.bitbangio"]
unittest.raiseException = True # terminates with stack information on userspace Exception
unittest.raiseBaseException = True # terminates with stack information on system Exception


+ 14
- 1
test/src/testing/adafruit_blinka.py View File

@ -36,4 +36,17 @@ class TestEnum(unittest.TestCase):
def test_str(self):
"""A str() call on an Enum performs the same as repr()"""
self.assertEqual(str(self.Cls.one), repr(self.Cls.one))
self.assertEqual(str(self.Cls.one), repr(self.Cls.one))
class TestDigitalInOut(unittest.TestCase):
def test_context_manager(self):
import digitalio
from testing.board import default_pin
"""Deinitialisation is triggered by __exit__() and should dispose machine.pin reference"""
dio = digitalio.DigitalInOut(default_pin)
self.assertIsNotNone(dio._pin)
with dio:
pass
self.assertIsNone(dio._pin)

+ 0
- 0
test/src/testing/implementation/all/__init__.py View File


+ 0
- 0
test/src/testing/implementation/circuitpython/__init__.py View File


+ 0
- 0
test/src/testing/implementation/circuitpython/digitalio.py View File


+ 0
- 8
test/src/testing/implementation/micropython/__init__.py View File

@ -1,8 +0,0 @@
def create_pin():
from microcontroller import Pin
name, pin = next(Pin.iteritems()) # grab first pin
return pin
def create_dio():
import digitalio
return digitalio.DigitalInOut(create_pin())

+ 0
- 21
test/src/testing/implementation/micropython/digitalio.py View File

@ -1,21 +0,0 @@
"""
Tests which require an embedded platform (with actual hardware bindings)
but which are not architecture-specific.
"""
import unittest
import digitalio
from testing.board import default_pin
class TestDigitalInOut(unittest.TestCase):
def test_context_manager(self):
"""Deinitialisation is triggered by __exit__() and should dispose machine.pin reference"""
dio = digitalio.DigitalInOut(default_pin)
self.assertIsNotNone(dio._pin)
with dio:
pass
self.assertIsNone(dio._pin)
def main():
unittest.main()

+ 0
- 11
test/src/testing/profiling/__init__.py View File

@ -1,11 +0,0 @@
def time_function(f):
import utime
"""From http://docs.micropython.org/en/latest/esp8266/reference/speed_python.html"""
myname = str(f).split(' ')[1]
def new_func(*args, **kwargs):
t = utime.ticks_us()
result = f(*args, **kwargs)
delta = utime.ticks_diff(utime.ticks_us(), t)
print('Function {} Time = {:6.3f}ms'.format(myname, delta/1000))
return result
return new_func

test/src/testing/implementation/__init__.py → test/src/testing/universal/__init__.py View File


test/src/testing/implementation/all/digitalio.py → test/src/testing/universal/digitalio.py View File


test/src/testing/implementation/all/i2c.py → test/src/testing/universal/i2c.py View File


test/src/testing/implementation/all/microcontroller.py → test/src/testing/universal/microcontroller.py View File


test/src/testing/implementation/all/uart.py → test/src/testing/universal/uart.py View File


Loading…
Cancel
Save