Skip to content

Commit d3bb3e3

Browse files
committed
tests/pyb: Adjust tests so they can run on PYB and PYBLITE.
A few tests still fail on PYBLITE, and that's due to differences in the available peripheral block numbers on the different MCUs (eg I2C(2) exists on one, but it's I2C(3) on the other).
1 parent 27c149e commit d3bb3e3

File tree

14 files changed

+57
-24
lines changed

14 files changed

+57
-24
lines changed

tests/pyb/adc.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,25 @@
99
val = adc.read()
1010
assert val < 500
1111

12+
# timer for read_timed
13+
tim = pyb.Timer(5, freq=500)
14+
1215
# read into bytearray
1316
buf = bytearray(50)
14-
adc.read_timed(buf, 500)
17+
adc.read_timed(buf, tim)
1518
print(len(buf))
1619
for i in buf:
1720
assert i < 500
1821

1922
# read into arrays with different element sizes
2023
import array
2124
ar = array.array('h', 25 * [0])
22-
adc.read_timed(ar, 500)
25+
adc.read_timed(ar, tim)
2326
print(len(ar))
2427
for i in buf:
2528
assert i < 500
2629
ar = array.array('i', 30 * [0])
27-
adc.read_timed(ar, 500)
30+
adc.read_timed(ar, tim)
2831
print(len(ar))
2932
for i in buf:
3033
assert i < 500

tests/pyb/can.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
from pyb import CAN
1+
try:
2+
from pyb import CAN
3+
except ImportError:
4+
print('SKIP')
5+
import sys
6+
sys.exit()
7+
28
import pyb
39

410
# test we can correctly create by id or name

tests/pyb/dac.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import pyb
22

3+
if not hasattr(pyb, 'DAC'):
4+
print('SKIP')
5+
import sys
6+
sys.exit()
7+
38
dac = pyb.DAC(1)
49
print(dac)
510
dac.noise(100)

tests/pyb/extint.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import pyb
22

33
# test basic functionality
4-
ext = pyb.ExtInt('X1', pyb.ExtInt.IRQ_RISING, pyb.Pin.PULL_DOWN, lambda l:print('line:', l))
4+
ext = pyb.ExtInt('Y1', pyb.ExtInt.IRQ_RISING, pyb.Pin.PULL_DOWN, lambda l:print('line:', l))
55
ext.disable()
66
ext.enable()
77
print(ext.line())

tests/pyb/extint.py.exp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
0
2-
line: 0
3-
line: 0
1+
6
2+
line: 6
3+
line: 6

tests/pyb/pin.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
from pyb import Pin
22

3-
p = Pin('X1', Pin.IN)
3+
p = Pin('Y1', Pin.IN)
44
print(p)
55
print(p.name())
66
print(p.pin())
77
print(p.port())
88

9-
p = Pin('X1', Pin.IN, Pin.PULL_UP)
10-
p = Pin('X1', Pin.IN, pull=Pin.PULL_UP)
11-
p = Pin('X1', mode=Pin.IN, pull=Pin.PULL_UP)
9+
p = Pin('Y1', Pin.IN, Pin.PULL_UP)
10+
p = Pin('Y1', Pin.IN, pull=Pin.PULL_UP)
11+
p = Pin('Y1', mode=Pin.IN, pull=Pin.PULL_UP)
1212
print(p)
1313
print(p.value())
1414

tests/pyb/pin.py.exp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
Pin(Pin.cpu.A0, mode=Pin.IN)
2-
A0
3-
0
4-
0
5-
Pin(Pin.cpu.A0, mode=Pin.IN, pull=Pin.PULL_UP)
1+
Pin(Pin.cpu.C6, mode=Pin.IN)
2+
C6
3+
6
4+
2
5+
Pin(Pin.cpu.C6, mode=Pin.IN, pull=Pin.PULL_UP)
66
1
7-
Pin(Pin.cpu.A0, mode=Pin.IN, pull=Pin.PULL_DOWN)
7+
Pin(Pin.cpu.C6, mode=Pin.IN, pull=Pin.PULL_DOWN)
88
0
99
0
1010
1

tests/pyb/pyb1.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,10 @@
2727
pyb.disable_irq()
2828
pyb.enable_irq()
2929

30-
print(pyb.freq())
31-
3230
print(pyb.have_cdc())
3331

3432
pyb.hid((0, 0, 0, 0)) # won't do anything
3533

36-
pyb.rng()
37-
3834
pyb.sync()
3935

4036
print(len(pyb.unique_id()))

tests/pyb/pyb1.py.exp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
3
22
3
3-
(168000000, 168000000, 42000000, 84000000)
43
True
54
12

tests/pyb/pyb_f405.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# test pyb module on F405 MCUs
2+
3+
import os, pyb
4+
5+
if not 'STM32F405' in os.uname().machine:
6+
print('SKIP')
7+
import sys
8+
sys.exit()
9+
10+
print(pyb.freq())
11+
print(type(pyb.rng()))

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy