|
17 | 17 | class TestDevicePortManagement: |
18 | 18 |
|
19 | 19 | def test_device_marker_enables_correct_port(self): |
20 | | - """@device('D455') should call enable_only(['111'], recycle=True).""" |
| 20 | + """@device('D455') enables the device (recycle=False -- the power cycle is |
| 21 | + teardown-disable + setup-enable, so setup itself doesn't recycle).""" |
21 | 22 | rc, out, tracking = run_e2e("pytest-device-setup.py", "-k", "test_d455 and not excluded") |
22 | 23 | assert_outcomes(out, passed=1) |
23 | 24 | assert len(tracking["enable_only_calls"]) == 1 |
24 | 25 | assert tracking["enable_only_calls"][0]['serials'] == ['111'] |
| 26 | + assert tracking["enable_only_calls"][0]['recycle'] is False |
| 27 | + |
| 28 | + def test_hubless_recycles_via_hw_reset(self): |
| 29 | + """On a hub-less bench (e.g. Jetson) teardown-disable is a no-op, so setup MUST recycle -- |
| 30 | + enable_only(recycle=True) falls back to hardware_reset. pytest-hubless-setup.py patches |
| 31 | + devices.hub to None to exercise the no-hub branch of the conftest recycle decision.""" |
| 32 | + rc, out, tracking = run_e2e("pytest-hubless-setup.py") |
| 33 | + assert_outcomes(out, passed=1) |
| 34 | + assert len(tracking["enable_only_calls"]) == 1 |
| 35 | + assert tracking["enable_only_calls"][0]['recycle'] is True |
| 36 | + |
| 37 | + def test_port_already_on_recycles(self): |
| 38 | + """With a hub, setup expects the device OFF (prev teardown disabled it). If a required port |
| 39 | + is still powered -- a skipped/crashed teardown -- setup recycles it clean instead of reusing |
| 40 | + a stale state. pytest-port-already-on.py patches any_port_powered -> True for this branch.""" |
| 41 | + rc, out, tracking = run_e2e("pytest-port-already-on.py") |
| 42 | + assert_outcomes(out, passed=1) |
| 43 | + assert len(tracking["enable_only_calls"]) == 1 |
25 | 44 | assert tracking["enable_only_calls"][0]['recycle'] is True |
26 | 45 |
|
27 | 46 | def test_device_each_enables_one_port_per_test(self): |
28 | | - """@device_each('D400*') should call enable_only once per device, each with recycle=True.""" |
| 47 | + """@device_each('D400*') should call enable_only once per device (recycle=False).""" |
29 | 48 | rc, out, tracking = run_e2e("pytest-each-setup.py", "-k", "test_d400 and not d999") |
30 | 49 | assert_outcomes(out, passed=3) |
31 | 50 | assert len(tracking["enable_only_calls"]) == 3 |
32 | 51 | serials_enabled = [c['serials'][0] for c in tracking["enable_only_calls"]] |
33 | 52 | assert set(serials_enabled) == {'111', '222', '777'} |
34 | | - assert all(c['recycle'] is True for c in tracking["enable_only_calls"]) |
| 53 | + assert all(c['recycle'] is False for c in tracking["enable_only_calls"]) |
35 | 54 | assert all(len(c['serials']) == 1 for c in tracking["enable_only_calls"]) |
36 | 55 |
|
37 | 56 | def test_second_test_same_device_no_recycle(self): |
|
0 commit comments