Coverage for tests/test_000_frigid/test_600_sequences.py: 100%
26 statements
« prev ^ index » next coverage.py v7.6.10, created at 2025-01-24 04:09 +0000
« prev ^ index » next coverage.py v7.6.10, created at 2025-01-24 04: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 sequence utilities. '''
24from . import PACKAGE_NAME, cache_import_module
27MODULE_QNAME = f"{PACKAGE_NAME}.sequences"
30def test_100_one_basic_operation( ):
31 ''' One function creates single-item tuples. '''
32 module = cache_import_module( MODULE_QNAME )
33 assert ( 42, ) == module.one( 42 )
34 assert ( None, ) == module.one( None )
35 assert ( 'test', ) == module.one( 'test' )
36 nested = module.one( module.one( 42 ) )
37 assert ( ( 42, ), ) == nested
40def test_300_one_with_generator( ):
41 ''' One function works in generator expressions. '''
42 module = cache_import_module( MODULE_QNAME )
43 result = tuple( module.one( x ) for x in range( 3 ) )
44 assert ( ( 0, ), ( 1, ), ( 2, ) ) == result
47def test_301_one_with_comprehension( ):
48 ''' One function works in list comprehensions. '''
49 module = cache_import_module( MODULE_QNAME )
50 result = [ module.one( x ) for x in range( 3 ) ]
51 assert [ ( 0, ), ( 1, ), ( 2, ) ] == result
54def test_302_one_with_map( ):
55 ''' One function works with map. '''
56 module = cache_import_module( MODULE_QNAME )
57 result = tuple( map( module.one, range( 3 ) ) )
58 assert ( ( 0, ), ( 1, ), ( 2, ) ) == result
61def test_900_docstring_sanity( ):
62 ''' Function has valid docstring. '''
63 module = cache_import_module( MODULE_QNAME )
64 assert hasattr( module.one, '__doc__' )
65 assert isinstance( module.one.__doc__, str )
66 assert module.one.__doc__