Skip to content

Commit

Permalink
Use custom TestCase-class
Browse files Browse the repository at this point in the history
  • Loading branch information
tstenner committed Feb 5, 2017
1 parent c2e3133 commit 7e5af79
Show file tree
Hide file tree
Showing 20 changed files with 90 additions and 211 deletions.
2 changes: 1 addition & 1 deletion tests/TestAction.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def dir_is_empty(dirname):
return not os.listdir(dirname)


class ActionTestCase(unittest.TestCase, common.AssertFile):
class ActionTestCase(common.BleachbitTestCase):

"""Test cases for Action"""

Expand Down
11 changes: 1 addition & 10 deletions tests/TestCLI.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@
import unittest



class CLITestCase(unittest.TestCase):
class CLITestCase(common.BleachbitTestCase):

"""Test case for module CLI"""

Expand Down Expand Up @@ -170,11 +169,3 @@ def test_shred(self):
args = [sys.executable, '-m', 'bleachbit.CLI', '--shred', filename]
output = run_external(args, stdout=open(os.devnull, 'w'))
self.assert_(not os.path.exists(filename))


def suite():
return unittest.makeSuite(CLITestCase)


if __name__ == '__main__':
unittest.main()
9 changes: 1 addition & 8 deletions tests/TestCleaner.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def actions_to_cleaner(action_strs):
return cleaner


class CleanerTestCase(unittest.TestCase, common.AssertFile):
class CleanerTestCase(common.BleachbitTestCase):

def test_add_action(self):
"""Unit test for Cleaner.add_action()"""
Expand Down Expand Up @@ -234,10 +234,3 @@ def test_whitelist(self):
for test in tests:
self.assertEqual(
backends['system'].whitelisted(test[0]), test[1], test[0])


def suite():
return unittest.makeSuite(CleanerTestCase)

if __name__ == '__main__':
unittest.main()
10 changes: 1 addition & 9 deletions tests/TestCleanerML.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import unittest


class CleanerMLTestCase(unittest.TestCase, common.AssertFile):
class CleanerMLTestCase(common.BleachbitTestCase):

"""Test cases for CleanerML"""

Expand Down Expand Up @@ -98,11 +98,3 @@ def test_load_cleaners(self):
def test_pot_fragment(self):
"""Unit test for pot_fragment()"""
self.assert_(isinstance(pot_fragment("Foo", 'bar.xml'), str))


def suite():
return unittest.makeSuite(CleanerMLTestCase)


if __name__ == '__main__':
unittest.main()
11 changes: 1 addition & 10 deletions tests/TestCommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@
from bleachbit.Command import *

import tempfile
import unittest


class CommandTestCase(unittest.TestCase):
class CommandTestCase(common.BleachbitTestCase):

"""Test case for Command"""

Expand Down Expand Up @@ -80,11 +79,3 @@ def test_Function(self):
def test_Shred(self):
"""Unit test for Shred"""
self.test_Delete(Shred)


def suite():
return unittest.makeSuite(CommandTestCase)


if __name__ == '__main__':
unittest.main()
11 changes: 1 addition & 10 deletions tests/TestCommon.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,9 @@
import bleachbit

import os
import tempfile
import unittest


class CommonTestCase(unittest.TestCase, common.AssertFile):
class CommonTestCase(common.BleachbitTestCase):

"""Test case for Common."""

Expand Down Expand Up @@ -78,10 +76,3 @@ def test_expanduser(self):
# A relative path (without a reference to the home directory)
# should not be expanded.
self.assertEqual(bleachbit.expanduser('common'), 'common')

def suite():
return unittest.makeSuite(CommonTestCase)


if __name__ == '__main__':
unittest.main()
11 changes: 1 addition & 10 deletions tests/TestDeepScan.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,9 @@
import os
import shutil
import tempfile
import unittest


class DeepScanTestCase(unittest.TestCase):
class DeepScanTestCase(common.BleachbitTestCase):

"""Test Case for module DeepScan"""

Expand Down Expand Up @@ -153,11 +152,3 @@ def test_normalized_walk_darwin(self):
]
mock_walk.return_value = expected
self.assertEqual(list(normalized_walk('.')), expected)


def suite():
return unittest.makeSuite(DeepScanTestCase)


if __name__ == '__main__':
unittest.main()
14 changes: 2 additions & 12 deletions tests/TestDiagnostic.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,12 @@
from tests import common
from bleachbit.Diagnostic import diagnostic_info

import unittest

class DiagnosticTestCase(unittest.TestCase):

class DiagnosticTestCase(common.BleachbitTestCase):
"""Test Case for module Diagnostic"""

def test_diagnostic_info(self):
"""Test diagnostic_info"""
# at least it does not crash
ret = diagnostic_info()
self.assert_(isinstance(ret, (str, unicode)))


def suite():
return unittest.makeSuite(DiagnosticTestCase)


if __name__ == '__main__':
unittest.main()
self.assertIsString(ret, (str, unicode))
17 changes: 2 additions & 15 deletions tests/TestFileUtilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@
import unittest





def test_ini_helper(self, execute):
"""Used to test .ini cleaning in TestAction and in TestFileUtilities"""

Expand Down Expand Up @@ -116,8 +113,7 @@ def load_js(js_fn):
self.assert_(not os.path.exists(filename))


class FileUtilitiesTestCase(unittest.TestCase, common.AssertFile):

class FileUtilitiesTestCase(common.BleachbitTestCase):
"""Test case for module FileUtilities"""

def test_bytes_to_human(self):
Expand Down Expand Up @@ -481,8 +477,7 @@ def test_getsize(self):
dirname = tempfile.mkdtemp(prefix='bleachbit-test-getsize')

def test_getsize_helper(fname):
filename = os.path.join(dirname, fname)
common.write_file(filename, "abcdefghij" * 12345)
filename = self.write_file(fname, "abcdefghij" * 12345)

if 'nt' == os.name:
self.assertEqual(getsize(filename), 10 * 12345)
Expand Down Expand Up @@ -895,11 +890,3 @@ def test_open_files_lsof(self):
self.assertEqual(list(open_files_lsof(lambda:
'n/bar/foo\nn/foo/bar\nnoise'
)), ['/bar/foo', '/foo/bar'])


def suite():
return unittest.makeSuite(FileUtilitiesTestCase)


if __name__ == '__main__':
unittest.main()
10 changes: 1 addition & 9 deletions tests/TestGeneral.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import unittest


class GeneralTestCase(unittest.TestCase):
class GeneralTestCase(common.BleachbitTestCase):

"""Test case for module General"""

Expand Down Expand Up @@ -168,11 +168,3 @@ def test_run_external_clean_env(self):
def test_sudo_mode(self):
"""Unit test for sudo_mode"""
self.assert_(isinstance(sudo_mode(), bool))


def suite():
return unittest.makeSuite(GeneralTestCase)


if __name__ == '__main__':
unittest.main()
11 changes: 1 addition & 10 deletions tests/TestMemory.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,13 @@
from tests import common
from bleachbit.Memory import *


import unittest
import sys

running_linux = sys.platform.startswith('linux')


class MemoryTestCase(unittest.TestCase):
class MemoryTestCase(common.BleachbitTestCase):
"""Test case for module Memory"""

@unittest.skipUnless(running_linux, 'not running linux')
Expand Down Expand Up @@ -143,11 +142,3 @@ def test_swap_off_swap_on(self):
self.skipTest('not enough privileges')
devices = disable_swap_linux()
enable_swap_linux()


def suite():
return unittest.makeSuite(MemoryTestCase)


if __name__ == '__main__':
unittest.main()
12 changes: 2 additions & 10 deletions tests/TestOptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@

from __future__ import absolute_import, print_function

from tests import common
import bleachbit.Options
from bleachbit import NoOptionError

import os
import unittest


class OptionsTestCase(unittest.TestCase):
class OptionsTestCase(common.BleachbitTestCase):

"""Test case for class Options"""

Expand Down Expand Up @@ -160,11 +160,3 @@ def test_abbreviations(self):

# clean up
del o


def suite():
return unittest.makeSuite(OptionsTestCase)


if __name__ == '__main__':
unittest.main()
12 changes: 2 additions & 10 deletions tests/TestRecognizeCleanerML.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@

from __future__ import absolute_import, print_function

from tests import common
from bleachbit.RecognizeCleanerML import hashdigest

import unittest


class RecognizeCleanerMLTestCase(unittest.TestCase):
class RecognizeCleanerMLTestCase(common.BleachbitTestCase):

"""Test case for RecognizeCleanerML"""

Expand All @@ -39,10 +38,3 @@ def test_hash(self):
self.assertEqual(len(digest), 128)
self.assertEqual(digest[1:10], '6382c203e')


def suite():
return unittest.makeSuite(RecognizeCleanerMLTestCase)


if __name__ == '__main__':
unittest.main()
11 changes: 1 addition & 10 deletions tests/TestSpecial.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import shutil
import sqlite3
import tempfile
import unittest


chrome_bookmarks = """
Expand Down Expand Up @@ -187,7 +186,7 @@ def assertTableIsEmpty(self, path, table):
raise AssertionError('Table is not empty: %s ' % table)


class SpecialTestCase(unittest.TestCase, SpecialAssertions):
class SpecialTestCase(common.BleachbitTestCase, SpecialAssertions):

"""Test case for module Special"""

Expand Down Expand Up @@ -383,11 +382,3 @@ def test_get_sqlite_int(self):
ver = Special.get_sqlite_int(
filename, 'select value from meta where key="version"')
self.assertEqual(ver, [20])


def suite():
return unittest.makeSuite(SpecialTestCase)


if __name__ == '__main__':
unittest.main()
10 changes: 1 addition & 9 deletions tests/TestUnix.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@


@unittest.skipIf('win32' == sys.platform, 'skipping unix tests on windows')
class UnixTestCase(unittest.TestCase):
class UnixTestCase(common.BleachbitTestCase):

"""Test case for module Unix"""

Expand Down Expand Up @@ -243,11 +243,3 @@ def test_yum_clean(self):
bytes_freed = yum_clean()
self.assert_(isinstance(bytes_freed, (int, long)))
bleachbit.logger.debug('yum bytes cleaned %d', bytes_freed)


def suite():
return unittest.makeSuite(UnixTestCase)


if __name__ == '__main__' and 'posix' == os.name:
unittest.main()
11 changes: 1 addition & 10 deletions tests/TestUpdate.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,9 @@

import os
import os.path
import unittest


class UpdateTestCase(unittest.TestCase):
class UpdateTestCase(common.BleachbitTestCase):

"""Test case for module Update"""

Expand Down Expand Up @@ -157,11 +156,3 @@ def test_environment(self):
import socket
self.assertTrue(hasattr(socket, 'ssl'))
import _ssl


def suite():
return unittest.makeSuite(UpdateTestCase)


if __name__ == '__main__':
unittest.main()
Loading

0 comments on commit 7e5af79

Please sign in to comment.