Change:
Faulty method of the class can expose itself only during function tests. Case when number of balls to draw is higher than number of balls in hat is not tested explicitly, but it can fail function test, as it includes such experiment. - - Depending on the number of balls to draw and number of balls in Hat: Remove the required number of balls randomly selected, from the Hat. If number of balls to draw is higher than the number of balls, return all the balls. Test for the method checks only the first case: The second behavior is not checked explicitly, but it's a part of the second sub-case in the function test. This creates situation where passing method test and failing function test, can suggest to camper that issue lies in the function. Example with faulty method: Error: Adding test to check second behavior of the method would make debugging easier for campers, as it would show more clearly where is the issue. No response n/a No response

Discussion:
reload(probability_calculator) probability_calculator.random.seed(95) <del> def test_hat_draw(self): </del> <ins> class UnitTests(unittest.TestCase): maxDiff = None def test_hat_draw(self): </ins> hat = probability_calculator.Hat(red=5,blue=2) actual = hat.draw(2) expected = ['blue', 'red']

}); ``` <ins> The `draw` method should behave correctly when the number of balls to extract is bigger than the number of balls in the hat. ```js ({ test: () => { pyodide.FS.writeFile("/home/pyodide/probability_calculator.py", code); pyodide.FS.writeFile( "/home/pyodide/test_module.py", ` import unittest import probability_calculator from importlib import reload reload(probability_calculator) probability_calculator.random.seed(95) class UnitTests(unittest.TestCase): maxDiff = None def test_hat_draw_2(self): hat = probability_calculator.Hat(yellow=5,red=1,green=3,blue=9,test=1) actual = hat.draw(20) expected = ['yellow', 'yellow', 'yellow', 'yellow', 'yellow', 'red', 'green', 'green', 'green', 'blue', 'blue', 'blue', 'blue', 'blue', 'blue', 'blue', 'blue', 'blue', 'test'] self.assertEqual(actual, expected, 'Expected hat draw to return all items from hat contents.') actual = len(hat.contents) expected = 0 self.assertEqual(actual, expected, 'Expected hat draw to leave no items in contents.') ` ); const testCode = ` from unittest import main import test_module from importlib import reload reload(test_module) t = main(module='test_module', exit=False) t.result.wasSuccessful() `; const out = __pyodide.runPython(testCode); assert(out); }, }); ``` </ins> The `experiment` method should return a different probability.

def draw(self, number): drawn = [] if number >= len(self.contents): <del> return self.contents </del> <ins> drawn.extend(self.contents) self.contents = [] </ins> else: for i in range(number): drawn.append(

) return drawn <del> def experiment(hat, expected_balls, num_balls_drawn, num_experiments): </del> <ins> def experiment(hat, expected_balls, num_balls_drawn, num_experiments): </ins> expected_balls_list = [] drawn_list = [] success = 0

except: continue if len(exp_ball_list_copy) == 0: <del> success += 1 probability = success/num_experiments </del> <ins> success += 1 probability = success/num_experiments </ins> return probability ```