MCPcopy Create free account
hub / github.com/bleachbit/bleachbit / test_dnf_autoremove_mock

Method test_dnf_autoremove_mock

tests/TestUnix.py:747–766  ·  view source on GitHub ↗

Unit test for dnf_autoremove() with mock

(self, mock_run, mock_path, mock_setup)

Source from the content-addressed store, hash-verified

745 @mock.patch('bleachbit.Unix.os.path')
746 @mock.patch('bleachbit.General.run_external')
747 def test_dnf_autoremove_mock(self, mock_run, mock_path, mock_setup):
748 """Unit test for dnf_autoremove() with mock"""
749 # Don't call setup_translation() for real because it uses
750 # os.path.exists(), which is mocked here.
751 mock_setup.return_value = None
752 mock_path.exists.return_value = True
753 self.assertRaises(RuntimeError, dnf_autoremove)
754
755 mock_path.exists.return_value = False
756 mock_run.return_value = (1, 'stdout', 'stderr')
757 self.assertRaises(RuntimeError, dnf_autoremove)
758
759 mock_run.return_value = (0, 'Nothing to do.', 'stderr')
760 bytes_freed = dnf_autoremove()
761 self.assertEqual(bytes_freed, 0)
762
763 mock_run.return_value = (
764 0, 'Remove 112 Packages\nFreed space: 299 M\n', 'stderr')
765 bytes_freed = dnf_autoremove()
766 self.assertEqual(bytes_freed, 299000000)
767
768 @common.skipIfWindows
769 def test_pacman_cache(self):

Callers

nothing calls this directly

Calls 1

dnf_autoremoveFunction · 0.90

Tested by

no test coverage detected