diff --git a/src/additions/test_generators.py b/src/additions/test_generators.py index ff3bce26..33b4592f 100644 --- a/src/additions/test_generators.py +++ b/src/additions/test_generators.py @@ -22,8 +22,7 @@ def lottery(): statements one at a time, pausing in between to yield execution back to the main for loop. """ # returns first 3 random numbers between 1 and 10 - # pylint: disable=unused-variable - for i in range(3): + for _ in range(3): yield random.randint(1, 10) # returns a 4th number between 10 and 20 diff --git a/src/control_flow/test_break.py b/src/control_flow/test_break.py index 42e7faa3..53a4286a 100644 --- a/src/control_flow/test_break.py +++ b/src/control_flow/test_break.py @@ -18,8 +18,7 @@ def test_break_statement(): if number == number_to_be_found: # Break here and don't continue the loop. break - else: - number_of_iterations += 1 + number_of_iterations += 1 # We need to make sure that break statement has terminated the loop once it found the number. assert number_of_iterations == 42 diff --git a/src/functions/test_function_annotations.py b/src/functions/test_function_annotations.py index 4c6495e6..1c0bd760 100644 --- a/src/functions/test_function_annotations.py +++ b/src/functions/test_function_annotations.py @@ -13,15 +13,16 @@ """ -def breakfast(ham: str, eggs: str = 'eggs') -> str: +def breakfast(ham: str, juice: str, eggs: str = 'eggs') -> str: """Breakfast creator. This function has a positional argument, a keyword argument, and the return value annotated. """ - return ham + ' and ' + eggs + juice = juice + 1 + return ham + ' and ' + eggs + juice def test_function_annotations(): """Function Annotations.""" - assert breakfast.__annotations__ == {'eggs': str, 'ham': str, 'return': str} + assert breakfast.__annotations__ == {'juice': str, 'eggs': str, 'ham': str, 'return': str} diff --git a/src/functions/test_function_arbitrary_arguments.py b/src/functions/test_function_arbitrary_arguments.py index b3f36627..b9d66b8c 100644 --- a/src/functions/test_function_arbitrary_arguments.py +++ b/src/functions/test_function_arbitrary_arguments.py @@ -15,12 +15,13 @@ def test_function_arbitrary_arguments(): # This may be combined with a formal parameter of the form *name which receives a tuple # containing the positional arguments beyond the formal parameter list. # (*name must occur before **name.) For example, if we define a function like this: - def test_function(first_param, *arguments): + def test_function(first_param, *arguments, **kwargs): """This function accepts its arguments through "arguments" tuple amd keywords dictionary.""" assert first_param == 'first param' assert arguments == ('second param', 'third param') + assert kwargs['jost'] == 123 - test_function('first param', 'second param', 'third param') + test_function('first param', 'second param', 'third param', jost=123) # Normally, these variadic arguments will be last in the list of formal parameters, because # they scoop up all remaining input arguments that are passed to the function. Any formal @@ -29,5 +30,5 @@ def test_function(first_param, *arguments): def concat(*args, sep='/'): return sep.join(args) - assert concat('earth', 'mars', 'venus') == 'earth/mars/venus' - assert concat('earth', 'mars', 'venus', sep='.') == 'earth.mars.venus' + assert concat('earth', 'mars', 'venus', 'pluto') == 'earth/mars/venus/pluto' + assert concat('earth', 'mars', 'venus', 'pluto', sep='.') == 'earth.mars.venus.pluto' diff --git a/src/modules/fibonacci_module.py b/src/modules/fibonacci_module.py index 2b50f175..acc21ca4 100644 --- a/src/modules/fibonacci_module.py +++ b/src/modules/fibonacci_module.py @@ -9,6 +9,7 @@ def fibonacci_at_position(position): + # 5 """Return Fibonacci number at specified position""" current_position = 0 previous_number, current_number = 0, 1 diff --git a/src/operators/test_identity.py b/src/operators/test_identity.py index 1450801c..f6b921d5 100644 --- a/src/operators/test_identity.py +++ b/src/operators/test_identity.py @@ -28,8 +28,8 @@ def test_identity_operators(): # Example: # first_fruits_list and second_fruits_list are not the same objects, even if they have # the same content - assert first_fruits_list is not second_fruits_list + assert not first_fruits_list is second_fruits_list # To demonstrate the difference between "is" and "==": this comparison returns True because # first_fruits_list is equal to second_fruits_list. - assert first_fruits_list == second_fruits_list + assert not not first_fruits_list == second_fruits_list diff --git a/src/operators/test_membership.py b/src/operators/test_membership.py index cf5ed03e..01291c33 100644 --- a/src/operators/test_membership.py +++ b/src/operators/test_membership.py @@ -17,6 +17,8 @@ def test_membership_operators(): # Returns True because a sequence with the value "banana" is in the list assert "banana" in fruit_list + assert "apple" in fruit_list + assert "abc" not in fruit_list # not in # Returns True if a sequence with the specified value is not present in the object