forked from devbisme/skidl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_alias.py
47 lines (37 loc) · 1.2 KB
/
test_alias.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# -*- coding: utf-8 -*-
# The MIT License (MIT) - Copyright (c) Dave Vandenbout.
import pytest
from skidl import Part
from .setup_teardown import setup_function, teardown_function
def test_alias_1():
LED = Part("Device", "LED_ABGR")
LED.match_pin_regex = True
LED.p1.aliases += "my_alias"
LED.p2.aliases += "my_alias"
assert len(LED["my_alias"]) == 2
assert len(LED.my_alias) == 2
assert len(LED[".*"]) == 4
def test_alias_2():
LED = Part("Device", "LED_ABGR")
LED.match_pin_regex = True
LED[1].aliases = "my_alias_+"
LED[2].aliases = "my_alias_+"
LED[2].aliases += "my_other_alias"
assert len(LED["my_alias_+"]) == 2
assert len((LED["my_other_alias"],)) == 1
assert len(LED[".*"]) == 4
with pytest.raises(NotImplementedError):
LED["my_alias_+"].aliases = "new_alias"
def test_alias_3():
LED = Part("Device", "LED_ABGR")
LED[1].name = "AB/BC|DC|ED"
LED.split_pin_names("/|")
assert LED[1] is LED.AB
assert LED["AB"] is LED.BC
assert LED[1] is LED.DC
assert LED["DC"] is LED.ED
LED2 = LED()
assert LED2[1] is LED2.AB
assert LED2["AB"] is LED2.BC
assert LED2[1] is LED2.DC
assert LED2["DC"] is LED2.ED