Skip to content

Instantly share code, notes, and snippets.

@bjbishop
Created April 17, 2020 18:18
Show Gist options
  • Save bjbishop/4dc65a200320ac4a646c1fdfe9488027 to your computer and use it in GitHub Desktop.
Save bjbishop/4dc65a200320ac4a646c1fdfe9488027 to your computer and use it in GitHub Desktop.
>pytest raindrops_test.py
================================== test session starts ==================================platform darwin -- Python 3.7.7, pytest-4.3.0, py-1.8.0, pluggy-0.8.1
rootdir: /Users/bishbr/src/exercism/python/raindrops, inifile:
collected 18 items
raindrops_test.py FFFFFFFFFFFFFFFFFF [100%]
======================================= FAILURES ========================================_ RaindropsTest.test_2_to_the_power_3_does_not_make_a_raindrop_sound_as_3_is_the_exponent_not_the_base _
self = <raindrops_test.RaindropsTest testMethod=test_2_to_the_power_3_does_not_make_a_raindrop_sound_as_3_is_the_exponent_not_the_base>
def test_2_to_the_power_3_does_not_make_a_raindrop_sound_as_3_is_the_exponent_not_the_base(
self
):
> self.assertEqual(convert(8), "8")
E AssertionError: '' != '8'
E + 8
raindrops_test.py:27: AssertionError
_ RaindropsTest.test_the_sound_for_105_is_pling_plang_plong_as_it_has_factors_3_5_and_7 _
self = <raindrops_test.RaindropsTest testMethod=test_the_sound_for_105_is_pling_plang_plong_as_it_has_factors_3_5_and_7>
def test_the_sound_for_105_is_pling_plang_plong_as_it_has_factors_3_5_and_7(self):
> self.assertEqual(convert(105), "PlingPlangPlong")
E AssertionError: '105' != 'PlingPlangPlong'
E - 105
E + PlingPlangPlong
raindrops_test.py:60: AssertionError
___________ RaindropsTest.test_the_sound_for_10_is_plang_as_it_has_a_factor_5 ___________
self = <raindrops_test.RaindropsTest testMethod=test_the_sound_for_10_is_plang_as_it_has_a_factor_5>
def test_the_sound_for_10_is_plang_as_it_has_a_factor_5(self):
> self.assertEqual(convert(10), "Plang")
E AssertionError: '10' != 'Plang'
E - 10
E + Plang
raindrops_test.py:33: AssertionError
_________ RaindropsTest.test_the_sound_for_14_is_plong_as_it_has_a_factor_of_7 __________
self = <raindrops_test.RaindropsTest testMethod=test_the_sound_for_14_is_plong_as_it_has_a_factor_of_7>
def test_the_sound_for_14_is_plong_as_it_has_a_factor_of_7(self):
> self.assertEqual(convert(14), "Plong")
E AssertionError: '14' != 'Plong'
E - 14
E + Plong
raindrops_test.py:36: AssertionError
_____ RaindropsTest.test_the_sound_for_15_is_pling_plang_as_it_has_factors_3_and_5 ______
self = <raindrops_test.RaindropsTest testMethod=test_the_sound_for_15_is_pling_plang_as_it_has_factors_3_and_5>
def test_the_sound_for_15_is_pling_plang_as_it_has_factors_3_and_5(self):
> self.assertEqual(convert(15), "PlingPlang")
E AssertionError: '15' != 'PlingPlang'
E - 15
E + PlingPlang
raindrops_test.py:39: AssertionError
________________________ RaindropsTest.test_the_sound_for_1_is_1 ________________________
self = <raindrops_test.RaindropsTest testMethod=test_the_sound_for_1_is_1>
def test_the_sound_for_1_is_1(self):
> self.assertEqual(convert(1), "1")
E AssertionError: '' != '1'
E + 1
raindrops_test.py:10: AssertionError
_____ RaindropsTest.test_the_sound_for_21_is_pling_plong_as_it_has_factors_3_and_7 ______
self = <raindrops_test.RaindropsTest testMethod=test_the_sound_for_21_is_pling_plong_as_it_has_factors_3_and_7>
def test_the_sound_for_21_is_pling_plong_as_it_has_factors_3_and_7(self):
> self.assertEqual(convert(21), "PlingPlong")
E AssertionError: '21' != 'PlingPlong'
E - 21
E + PlingPlong
raindrops_test.py:42: AssertionError
___________ RaindropsTest.test_the_sound_for_25_is_plang_as_it_has_a_factor_5 ___________
self = <raindrops_test.RaindropsTest testMethod=test_the_sound_for_25_is_plang_as_it_has_a_factor_5>
def test_the_sound_for_25_is_plang_as_it_has_a_factor_5(self):
> self.assertEqual(convert(25), "Plang")
E AssertionError: '25' != 'Plang'
E - 25
E + Plang
raindrops_test.py:45: AssertionError
___________ RaindropsTest.test_the_sound_for_27_is_pling_as_it_has_a_factor_3 ___________
self = <raindrops_test.RaindropsTest testMethod=test_the_sound_for_27_is_pling_as_it_has_a_factor_3>
def test_the_sound_for_27_is_pling_as_it_has_a_factor_3(self):
> self.assertEqual(convert(27), "Pling")
E AssertionError: '27' != 'Pling'
E - 27
E + Pling
raindrops_test.py:48: AssertionError
__________ RaindropsTest.test_the_sound_for_3125_is_plang_as_it_has_a_factor_5 __________
self = <raindrops_test.RaindropsTest testMethod=test_the_sound_for_3125_is_plang_as_it_has_a_factor_5>
def test_the_sound_for_3125_is_plang_as_it_has_a_factor_5(self):
> self.assertEqual(convert(3125), "Plang")
E AssertionError: '3125' != 'Plang'
E - 3125
E + Plang
raindrops_test.py:63: AssertionError
_____ RaindropsTest.test_the_sound_for_35_is_plang_plong_as_it_has_factors_5_and_7 ______
self = <raindrops_test.RaindropsTest testMethod=test_the_sound_for_35_is_plang_plong_as_it_has_factors_5_and_7>
def test_the_sound_for_35_is_plang_plong_as_it_has_factors_5_and_7(self):
> self.assertEqual(convert(35), "PlangPlong")
E AssertionError: '35' != 'PlangPlong'
E - 35
E + PlangPlong
raindrops_test.py:51: AssertionError
______________________ RaindropsTest.test_the_sound_for_3_is_pling ______________________
self = <raindrops_test.RaindropsTest testMethod=test_the_sound_for_3_is_pling>
def test_the_sound_for_3_is_pling(self):
> self.assertEqual(convert(3), "Pling")
E AssertionError: '3' != 'Pling'
E - 3
E + Pling
raindrops_test.py:13: AssertionError
___________ RaindropsTest.test_the_sound_for_49_is_plong_as_it_has_a_factor_7 ___________
self = <raindrops_test.RaindropsTest testMethod=test_the_sound_for_49_is_plong_as_it_has_a_factor_7>
def test_the_sound_for_49_is_plong_as_it_has_a_factor_7(self):
> self.assertEqual(convert(49), "Plong")
E AssertionError: '49' != 'Plong'
E - 49
E + Plong
raindrops_test.py:54: AssertionError
_______________________ RaindropsTest.test_the_sound_for_52_is_52 _______________________
self = <raindrops_test.RaindropsTest testMethod=test_the_sound_for_52_is_52>
def test_the_sound_for_52_is_52(self):
> self.assertEqual(convert(52), "52")
E AssertionError: '' != '52'
E + 52
raindrops_test.py:57: AssertionError
______________________ RaindropsTest.test_the_sound_for_5_is_plang ______________________
self = <raindrops_test.RaindropsTest testMethod=test_the_sound_for_5_is_plang>
def test_the_sound_for_5_is_plang(self):
> self.assertEqual(convert(5), "Plang")
E AssertionError: '5' != 'Plang'
E - 5
E + Plang
raindrops_test.py:16: AssertionError
___________ RaindropsTest.test_the_sound_for_6_is_pling_as_it_has_a_factor_3 ____________
self = <raindrops_test.RaindropsTest testMethod=test_the_sound_for_6_is_pling_as_it_has_a
_factor_3>
def test_the_sound_for_6_is_pling_as_it_has_a_factor_3(self):
> self.assertEqual(convert(6), "Pling")
E AssertionError: '6' != 'Pling'
E - 6
E + Pling
raindrops_test.py:22: AssertionError
______________________ RaindropsTest.test_the_sound_for_7_is_plong ______________________
self = <raindrops_test.RaindropsTest testMethod=test_the_sound_for_7_is_plong>
def test_the_sound_for_7_is_plong(self):
> self.assertEqual(convert(7), "Plong")
E AssertionError: '7' != 'Plong'
E - 7
E + Plong
raindrops_test.py:19: AssertionError
___________ RaindropsTest.test_the_sound_for_9_is_pling_as_it_has_a_factor_3 ____________
self = <raindrops_test.RaindropsTest testMethod=test_the_sound_for_9_is_pling_as_it_has_a
_factor_3>
def test_the_sound_for_9_is_pling_as_it_has_a_factor_3(self):
> self.assertEqual(convert(9), "Pling")
E AssertionError: '9' != 'Pling'
E - 9
E + Pling
raindrops_test.py:30: AssertionError
=============================== 18 failed in 0.14 seconds ===============================
@bjbishop
Copy link
Author

That's with this code:

def convert(number):
    # Convert a number to raindrops
    string = ""
    if number % 3 == 0:
        string += "Pling"
    if number % 5 == 0:
        string += "Plang"
    if number % 7 == 0:
        string += "Plong"
    if string:
        string = str(number)
    return string

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment