Unit test for run_cleaner_cmd()
(self)
| 678 | |
| 679 | @common.skipIfWindows |
| 680 | def test_run_cleaner_cmd(self): |
| 681 | """Unit test for run_cleaner_cmd()""" |
| 682 | self.assertRaises(RuntimeError, run_cleaner_cmd, |
| 683 | '/hopethisdoesntexist', []) |
| 684 | # Use absolute path in case like `env -i`. |
| 685 | which_sh = 'sh' if exe_exists('sh') else '/usr/bin/sh' |
| 686 | self.assertRaises(subprocess.CalledProcessError, run_cleaner_cmd, |
| 687 | which_sh, ['-c', 'echo errormsg; false']) |
| 688 | # test if regexes for invalid lines work |
| 689 | self.assertRaises(RuntimeError, run_cleaner_cmd, 'echo', ['This is an invalid line'], |
| 690 | error_line_regexes=['invalid']) |
| 691 | |
| 692 | freed_space_regex = r'^Freed ([\d.]+[kMT]?B)' |
| 693 | lines = ['Test line', |
| 694 | 'Freed 100B on your hard drive', |
| 695 | 'Freed 1.9kB, hooray!', |
| 696 | 'Fred 12MB'] |
| 697 | freed_space = run_cleaner_cmd( |
| 698 | 'echo', ['\n'.join(lines)], freed_space_regex) |
| 699 | self.assertEqual(freed_space, 2000) |
| 700 | |
| 701 | @common.skipIfWindows |
| 702 | def test_wine_to_linux_path(self): |
nothing calls this directly
no test coverage detected