tests.tools_tests module#

Test tools package alone which don’t fit into other tests.

class tests.tools_tests.AddStopList[source]#

Bases: set

Container that stops when encountering items.

add(item)[source]#

Override to not continue on encountering items.

stop_list = []#
class tests.tools_tests.BasicGeneratorIntersectTestCase(*args, **kwargs)[source]#

Bases: DisableSiteMixin, GeneratorIntersectTestCase

Disconnected intersect_generators test cases.

abstract_class = False#
test_intersect_basic()[source]#

Test basic intersect without duplicates.

test_intersect_with_accepted_dups()[source]#

Test intersect with duplicates accepted.

test_intersect_with_dups()[source]#

Test basic intersect with duplicates.

class tests.tools_tests.ContainsStopList[source]#

Bases: set

Container that stops when encountering items.

stop_list = []#
class tests.tools_tests.DecoratedMethods[source]#

Bases: object

Test class to verify cached decorator.

Initializer, reset read counter.

property bar#

A property.

baz()[source]#

An undecorated method.

foo()[source]#

A method.

method_with_args(*args, **kwargs)[source]#

Method with force.

quux(force=False)[source]#

Method with force.

class tests.tools_tests.Foo[source]#

Bases: object

Test class to verify classproperty decorator.

bar = 'baz'#
class tests.tools_tests.GeneratorIntersectTestCase(*args, **kwargs)[source]#

Bases: TestCase

Base class for intersect_generators test cases.

abstract_class = True#
assertEqualItertools(gens)[source]#

Assert intersect_generators result is same as set intersection.

assertEqualItertoolsWithDuplicates(gens)[source]#

Assert intersect_generators result equals Counter intersection.

class tests.tools_tests.MergeUniqueDicts(*args, **kwargs)[source]#

Bases: DisableSiteMixin, TestCase

Test merge_unique_dicts.

abstract_class = False#
dct1 = {'42': 'answer', 'foo': 'bar'}#
dct2 = {47: 'Star', 74: 'Trek'}#
dct_both = {'42': 'answer', 'foo': 'bar', 47: 'Star', 74: 'Trek'}#
test_conflict()[source]#

Test that it detects conflicts.

test_different_type()[source]#

Test that the keys can be different types.

test_multiple()[source]#

Test that it actually merges dicts.

test_single()[source]#

Test that it returns the dict itself when there is only one.

class tests.tools_tests.OpenArchiveTestCase(*args, **kwargs)[source]#

Bases: DisableSiteMixin, TestCase

Unit test class for tools.

The tests for open_archive requires that article-pyrus.xml* contain all the same content after extraction. The content itself is not important. The file article-pyrus.xml_invalid.7z is not a valid 7z file and open_archive will fail extracting it using 7za.

abstract_class = False#
classmethod setUpClass()[source]#

Define base_file and original_content.

test_open_archive_7z()[source]#

Test open_archive with 7za if installed.

test_open_archive_bz2()[source]#

Test open_archive with bz2 compressor in the standard library.

test_open_archive_gz()[source]#

Test open_archive with gz compressor in the standard library.

test_open_archive_lzma()[source]#

Test open_archive with lzma compressor in the standard library.

test_open_archive_normal()[source]#

Test open_archive with no compression in the standard library.

class tests.tools_tests.OpenArchiveWriteTestCase(*args, **kwargs)[source]#

Bases: DisableSiteMixin, TestCase

Test writing with open_archive.

abstract_class = False#
classmethod setUpClass()[source]#

Define base_file and original_content.

test_binary_mode()[source]#

Test that it uses binary mode.

test_invalid_modes()[source]#

Test various invalid mode configurations.

test_write_archive_7z()[source]#

Test writing an archive as a 7z archive.

test_write_archive_bz2()[source]#

Test writing a bz2 archive.

test_write_archive_gz()[source]#

Test writing a gz archive.

test_write_archive_lzma()[source]#

Test writing a lzma archive.

test_write_archive_xz()[source]#

Test writing a xz archive.

class tests.tools_tests.ProcessAgainList[source]#

Bases: set

Container that keeps processing certain items.

add(item)[source]#

Override to not add some items.

process_again_list = [1, 3]#
class tests.tools_tests.SkipList[source]#

Bases: set

Container that ignores items.

skip_list = [1, 3]#
class tests.tools_tests.TestClassProperty(*args, **kwargs)[source]#

Bases: DisableSiteMixin, TestCase

Test classproperty decorator.

abstract_class = False#
test_classproperty()[source]#

Test for classproperty decorator.

class tests.tools_tests.TestFileModeChecker(*args, **kwargs)[source]#

Bases: DisableSiteMixin, TestCase

Test parsing password files.

abstract_class = False#
patch(name)[source]#

Patch up <name> in self.setUp.

setUp()[source]#

Patch a variety of dependencies.

test_auto_chmod_OK()[source]#

Do not chmod files that have mode private_files_permission.

test_auto_chmod_for_dir()[source]#

Do not chmod files that have mode private_files_permission.

test_auto_chmod_not_OK()[source]#

Chmod files that do not have mode private_files_permission.

class tests.tools_tests.TestFileShaCalculator(*args, **kwargs)[source]#

Bases: DisableSiteMixin, TestCase

Test calculator of sha of a file.

There are two possible hash values for each test. The second one is for files with Windows line endings (rn).

abstract_class = False#
filename = '/src/tests/data/xml/article-pear-0.10.xml'#
md5_tests = {'function': functools.partial(<function hash_func>, 'md5'), 'hash': <built-in function openssl_md5>, 'str': 'md5'}#
test_md5_complete_calculation()[source]#

Test md5 of complete file.

test_md5_partial_calculation()[source]#

Test md5 of partial file (1024 bytes).

test_sha1_complete_calculation()[source]#

Test sha1 of complete file.

test_sha1_partial_calculation()[source]#

Test sha1 of partial file (1024 bytes).

test_sha224_complete_calculation()[source]#

Test sha224 of complete file.

test_sha224_partial_calculation()[source]#

Test sha224 of partial file (1024 bytes).

class tests.tools_tests.TestFilterUnique(*args, **kwargs)[source]#

Bases: DisableSiteMixin, TestCase

Test filter_unique.

abstract_class = False#
decs = [Decimal('1'), Decimal('3'), Decimal('2'), Decimal('1'), Decimal('2'), Decimal('1'), Decimal('2'), Decimal('4'), Decimal('2')]#
ints = [1, 3, 2, 1, 2, 1, 2, 4, 2]#
strs = ['1', '3', '2', '1', '2', '1', '2', '4', '2']#
test_OrderedDict()[source]#

Test filter_unique with an OrderedDict.

test_dict()[source]#

Test filter_unique with a dict.

test_for_resumable()[source]#

Test filter_unique is resumable after a for loop.

test_int_hash()[source]#

Test filter_unique with ints using hash as key.

test_int_id()[source]#

Test filter_unique with ints using id as key.

test_obj()[source]#

Test filter_unique with objects.

test_obj_hash()[source]#

Test filter_unique with objects using hash as key.

test_obj_id()[source]#

Test filter_unique with objects using id as key, which fails.

test_process_again()[source]#

Test filter_unique with an ignoring container.

test_set()[source]#

Test filter_unique with a set.

test_skip()[source]#

Test filter_unique with a container that skips items.

test_stop_add()[source]#

Test filter_unique with an ignoring container during add call.

test_stop_contains()[source]#

Test filter_unique with an ignoring container.

test_str()[source]#

Test filter_unique with str.

test_str_hash()[source]#

Test filter_unique with str using hash as key.

class tests.tools_tests.TestHasModule(*args, **kwargs)[source]#

Bases: DisableSiteMixin, TestCase

Unit test class for has_module.

abstract_class = False#
test_when_insufficient_version()[source]#

Test when the module is older than what we need.

test_when_missing()[source]#

Test when the module is unavailable.

test_when_present()[source]#

Test when the module is available.

class tests.tools_tests.TestIsIpAddress(*args, **kwargs)[source]#

Bases: DisableSiteMixin, TestCase

Unit test class for is_ip_address.

abstract_class = False#
test_invalid_ipv4_addresses()[source]#

Check with invalid IPv4 addresses.

test_invalid_ipv6_addresses()[source]#

Check with invalid IPv6 addresses.

test_valid_ipv4_addresses()[source]#

Check with valid IPv4 addresses.

test_valid_ipv6_addresses()[source]#

Check with valid IPv6 addresses.

class tests.tools_tests.TestIsIpNetwork(*args, **kwargs)[source]#

Bases: DisableSiteMixin, TestCase

Unit test class for is_ip_network.

abstract_class = False#
test_invalid_ipv4_ranges()[source]#

Check with invalid IPv4 address ranges.

test_invalid_ipv6_addresses()[source]#

Check with invalid IPv6 addresses.

test_valid_ipv4_ranges()[source]#

Check with valid IPv4 address ranges.

test_valid_ipv6_ranges()[source]#

Check with valid IPv6 address ranges.

class tests.tools_tests.TestIsSliceWithEllipsis(*args, **kwargs)[source]#

Bases: DisableSiteMixin, TestCase

Test islice_with_ellipsis.

abstract_class = False#
it = ['a', 'b', 'c', 'd', 'f']#
it_null = []#
test_do_not_show_marker()[source]#

Test marker is not shown when no marker is specified.

test_do_not_show_marker_when_get_all()[source]#

Test marker is not shown when all elements are retrieved.

test_do_not_show_marker_with_stop_zero()[source]#

Test marker is shown with stop for empty iterable.

test_show_custom_marker()[source]#

Test correct marker is shown with kwargs..

test_show_custom_marker_with_start_stop()[source]#

Test marker is shown with start and stop with kwargs.

test_show_default_marker()[source]#

Test marker is shown without kwargs.

test_show_marker_with_start_stop()[source]#

Test marker is shown with start and stop without kwargs.

test_show_marker_with_stop_zero()[source]#

Test marker is shown with stop for non empty iterable.

class tests.tools_tests.TestMergeGenerator(*args, **kwargs)[source]#

Bases: DisableSiteMixin, TestCase

Test merging generators.

abstract_class = False#
test_roundrobin_generators()[source]#

Test merge_generators generator.

class tests.tools_tests.TestStringFunctions(*args, **kwargs)[source]#

Bases: DisableSiteMixin, TestCase

Unit test class for string functions.

abstract_class = False#
test_first_lower()[source]#

Test first_lower function.

test_first_upper()[source]#

Test first_upper function.

test_strtobool()[source]#

Test strtobool function.

class tests.tools_tests.TestTinyCache(*args, **kwargs)[source]#

Bases: DisableSiteMixin, TestCase

Test cached decorator.

abstract_class = False#
setUp()[source]#

Setup tests.

test_cached()[source]#

Test for cached decorator.

test_cached_property()[source]#

Test for cached property decorator.

test_cached_with_argse()[source]#

Test method with args.

test_cached_with_force()[source]#

Test for cached decorator with force enabled.

test_cached_with_paramters()[source]#

Test for cached decorator with parameters.

tests.tools_tests.hash_func(digest)[source]#

Function who gives a hashlib function.

tests.tools_tests.passthrough(x)[source]#

Return x.