Skip to content

Commit

Permalink
Add alternative to test case
Browse files Browse the repository at this point in the history
Mark cases that are mixable at mixable_case.
Include the alternative case in the corresponding position in
expect[] with list.
Consider mixable case during assertEqual
  • Loading branch information
Deepskyhunter committed Jun 21, 2022
1 parent 4ede14b commit b6aa9c2
Showing 1 changed file with 41 additions and 9 deletions.
50 changes: 41 additions & 9 deletions artiq/test/test_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,18 +199,30 @@ def test_pending_priority(self):
"value": "prepare_done",
"key": "status"
},
{
[{
"path": [0],
"action": "setitem",
"value": "running",
"key": "status"
},
{
},
{
"path": [2],
"action": "setitem",
"value": "preparing",
"key": "status"
},
}],
[{
"path": [0],
"action": "setitem",
"value": "running",
"key": "status"
},
{
"path": [2],
"action": "setitem",
"value": "preparing",
"key": "status"
}],
{
"path": [2],
"action": "setitem",
Expand All @@ -235,18 +247,30 @@ def test_pending_priority(self):
"value": "run_done",
"key": "status"
},
{
[{
"path": [0],
"action": "setitem",
"value": "running",
"key": "status"
},
{
},
{
"path": [2],
"action": "setitem",
"value": "analyzing",
"key": "status"
},
}],
[{
"path": [0],
"action": "setitem",
"value": "running",
"key": "status"
},
{
"path": [2],
"action": "setitem",
"value": "analyzing",
"key": "status"
}],
{
"path": [2],
"action": "setitem",
Expand All @@ -259,11 +283,19 @@ def test_pending_priority(self):
"key": 2
},
]
mixable_case = [5, 6, 11, 12]
done = asyncio.Event()
expect_idx = 0

def notify(mod):
nonlocal expect_idx
self.assertEqual(mod, expect[expect_idx])
if expect_idx in mixable_case:
if mod == expect[expect_idx][0]:
self.assertEqual(mod, expect[expect_idx][0])
else:
self.assertEqual(mod, expect[expect_idx][1])
else:
self.assertEqual(mod, expect[expect_idx])
expect_idx += 1
if expect_idx >= len(expect):
done.set()
Expand Down

0 comments on commit b6aa9c2

Please sign in to comment.