MCPcopy
hub / github.com/trekhleb/learn-python / test_modules

Function test_modules

src/modules/test_modules.py:68–97  ·  view source on GitHub ↗

Modules

()

Source from the content-addressed store, hash-verified

66
67
68def test_modules():
69 """Modules"""
70
71 assert fibonacci_module.fibonacci_at_position(7) == 13
72 assert fibonacci_at_position(7) == 13
73 assert fibonacci_module_renamed.fibonacci_at_position(7) == 13
74 assert fibonacci_at_position_renamed(7) == 13
75
76 assert fibonacci_module.fibonacci_smaller_than(100) == [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
77 assert fibonacci_smaller_than(100) == [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
78 assert fibonacci_module_renamed.fibonacci_smaller_than(10) == [0, 1, 1, 2, 3, 5, 8]
79
80 # If you intend to use a function often you can assign it to a local name.
81 fibonacci = fibonacci_module.fibonacci_smaller_than
82 assert fibonacci(100) == [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
83
84 # The built-in function dir() is used to find out which names a module defines. It returns a
85 # sorted list of strings.
86 assert dir(fibonacci_module) == [
87 '__builtins__',
88 '__cached__',
89 '__doc__',
90 '__file__',
91 '__loader__',
92 '__name__',
93 '__package__',
94 '__spec__',
95 'fibonacci_at_position',
96 'fibonacci_smaller_than',
97 ]

Callers

nothing calls this directly

Calls 2

fibonacci_at_positionFunction · 0.90
fibonacci_smaller_thanFunction · 0.90

Tested by

no test coverage detected