Skip to content

Commit

Permalink
Cut down time it takes to run base provider unit tests by 95% (Infra) (
Browse files Browse the repository at this point in the history
…canonical#943)

mock out the sleeps in tests
  • Loading branch information
kissiel authored and binli committed Mar 22, 2024
1 parent ab93890 commit 5ac5c1e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion providers/base/tests/test_pipewire_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,9 @@ def test_wpctl_output_succ(self, mock_checkout):
'1'],
universal_newlines=True)

@patch("time.sleep")
@patch("subprocess.check_output")
def test_wpctl_output_fail(self, mock_checkout):
def test_wpctl_output_fail(self, mock_checkout, _):
vc = VolumeController(type='input', logger=MagicMock())
mock_checkout.side_effect = subprocess.CalledProcessError(2, "echo")
with self.assertRaises(SystemExit) as cm:
Expand Down
7 changes: 4 additions & 3 deletions providers/base/tests/test_pipewire_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,9 +385,9 @@ def test_wrong_gst_pipeline_device(self, mock_checkout):
mock_checkout.return_value = self.device
self.assertEqual(PipewireTestError.NO_SPECIFIC_DEVICE,
pt.gst_pipeline("pipe", 10, "qoo"))

@patch("time.sleep")
@patch("subprocess.check_output")
def test_gst_pipeline(self, mock_checkout):
def test_gst_pipeline(self, mock_checkout, _):
pt = PipewireTest()

mock_checkout.return_value = self.device
Expand Down Expand Up @@ -485,8 +485,9 @@ class MonitorActivePortTests(unittest.TestCase):
}
}]"""

@patch("time.sleep")
@patch("subprocess.check_output")
def test_couldnt_detect_change(self, mock_checkout):
def test_couldnt_detect_change(self, mock_checkout, _):
pt = PipewireTest()

mock_checkout.return_value = self.before_device
Expand Down

0 comments on commit 5ac5c1e

Please sign in to comment.