Coverage for tests/test_000_falsifier/test_100_objects.py: 100%
57 statements
« prev ^ index » next coverage.py v7.6.9, created at 2024-12-21 00:09 +0000
« prev ^ index » next coverage.py v7.6.9, created at 2024-12-21 00:09 +0000
1# vim: set filetype=python fileencoding=utf-8:
2# -*- coding: utf-8 -*-
4#============================================================================#
5# #
6# Licensed under the Apache License, Version 2.0 (the "License"); #
7# you may not use this file except in compliance with the License. #
8# You may obtain a copy of the License at #
9# #
10# http://www.apache.org/licenses/LICENSE-2.0 #
11# #
12# Unless required by applicable law or agreed to in writing, software #
13# distributed under the License is distributed on an "AS IS" BASIS, #
14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
15# See the License for the specific language governing permissions and #
16# limitations under the License. #
17# #
18#============================================================================#
21''' Assert correct function of Falsifier class. '''
24import pytest
26from . import PACKAGE_NAME, cache_import_module
29def test_100_instantiation( ):
30 ''' Class instantiates. '''
31 module = cache_import_module( f"{PACKAGE_NAME}.objects" )
32 obj = module.Falsifier( )
33 assert isinstance( obj, module.Falsifier )
36def test_101_boolean_evaluation( ):
37 ''' Object evaluates to False. '''
38 module = cache_import_module( f"{PACKAGE_NAME}.objects" )
39 obj = module.Falsifier( )
40 assert not obj
41 assert False == bool( obj ) # noqa: E712
44def test_102_equality( ):
45 ''' Object equality is identity-based. '''
46 module = cache_import_module( f"{PACKAGE_NAME}.objects" )
47 obj1 = module.Falsifier( )
48 obj2 = module.Falsifier( )
49 assert obj1 == obj1
50 assert obj1 != obj2
51 assert not (obj1 == obj2)
54def test_103_hash_uniqueness( ):
55 ''' Object hashes are unique. '''
56 module = cache_import_module( f"{PACKAGE_NAME}.objects" )
57 obj1 = module.Falsifier( )
58 obj2 = module.Falsifier( )
59 assert hash( obj1 ) != hash( obj2 )
60 assert hash( obj1 ) == hash( obj1 )
63def test_104_string_representations( ):
64 ''' Object has expected string representations. '''
65 module = cache_import_module( f"{PACKAGE_NAME}.objects" )
66 obj = module.Falsifier( )
67 assert 'False_' == str( obj )
68 assert f'{PACKAGE_NAME}.objects.Falsifier( )' == repr( obj )
71def test_105_ordering_operations( ):
72 ''' Object does not support ordering. '''
73 module = cache_import_module( f"{PACKAGE_NAME}.objects" )
74 obj1 = module.Falsifier( )
75 obj2 = module.Falsifier( )
76 with pytest.raises( TypeError ):
77 _ = obj1 < obj2
78 with pytest.raises( TypeError ):
79 _ = obj1 <= obj2
80 with pytest.raises( TypeError ):
81 _ = obj1 > obj2
82 with pytest.raises( TypeError ):
83 _ = obj1 >= obj2
86def test_106_collection_usage( ):
87 ''' Object works in collections. '''
88 module = cache_import_module( f"{PACKAGE_NAME}.objects" )
89 obj1 = module.Falsifier( )
90 obj2 = module.Falsifier( )
91 unique_set = { obj1, obj2, obj1 }
92 assert 2 == len( unique_set )
93 assert obj1 in unique_set
94 assert obj2 in unique_set
95 mapping = { obj1: 'first', obj2: 'second' }
96 assert 'first' == mapping[ obj1 ]
97 assert 'second' == mapping[ obj2 ]
100def test_900_docstring_sanity( ):
101 ''' Class has valid docstring. '''
102 module = cache_import_module( f"{PACKAGE_NAME}.objects" )
103 assert hasattr( module.Falsifier, '__doc__' )
104 assert isinstance( module.Falsifier.__doc__, str )
105 assert module.Falsifier.__doc__