Beispiel #1
0
 def test1(self):
     self.maxDiff = None  # Had to make test output max size unbounded (Also removed comma from fizzbuzz.txt)
     CompFile = open("fizzbuzz.txt", "r")  # Open fizzbuzz.txt
     with captured_output() as (out, err):
         fizzbuzz.fb()  # Call fizzbuzz
         output = out.getvalue().strip()  # Retrieve fb's output
         self.assertEqual(
             output, CompFile.read())  # Compare output against fizzbuzz.txt
Beispiel #2
0
    def test_fb(self):

        self.assertEqual(fb(1),"1")

        self.assertEqual(fb(3),"Fizz")

        self.assertEqual(fb(5),"Buzz")

        self.assertEqual(fb(15),"FizzBuzz")
 def test_num(self):
     """
     Test that it prints the number when not divisible by 3 nor by 5
     """
     result = fizzbuzz.fb(1)
     self.assertEqual(result, 1)
 def test_check_15(self):
     capturedOutput = io.StringIO()
     sys.stdout = capturedOutput
     fizzbuzz.fb()
     sys.stdout = sys.__stdout__
     self.assertNotIn('15', capturedOutput)
 def test_buzz(self):
     """
     Test that it prints 'Buzz' when divisible by 5
     """
     result = fizzbuzz.fb(5)
     self.assertEqual(result, 'Buzz')
 def test_fizzbuzz(self):
     """
     Test that it prints 'FizzBuzz' when divisible by 3 and by 5
     """
     result = fizzbuzz.fb(15)
     self.assertEqual(result, 'FizzBuzz')
Beispiel #7
0
def fizzbuzz(num: int):
    fb(num)
def test_fb():
    for i in range(len(inputs)):
        assert fb(inputs[i]) == results[i]
Beispiel #9
0
 def test_fizz(self):
     self.assertNotEqual(fizzbuzz.fb(), "1, 2, fizz, 4, 5, fizz, 7, 8, fizz, 10, 11, fizz, 13, 14, fizz, 16, 17, fizz, 19, 20, fizz, 22, 23, fizz, 25, 26, fizz, 28, 29, fizz, 31, 32, fizz, 34, 35, fizz, 37, 38, fizz, 40, 41, fizz, 43, 44, fizz, 46, 47, fizz, 49, 50, fizz, 52, 53, fizz, 55, 56, fizz, 58, 59, fizz, 61, 62, fizz, 64, 65, fizz, 67, 68, fizz, 70, 71, fizz, 73, 74, fizz, 76, 77, fizz, 79, 80, fizz, 82, 83, fizz, 85, 86, fizz, 88, 89, fizz, 91, 92, fizz, 94, 95, fizz, 97, 98, fizz, 100")
Beispiel #10
0
 def test_num(self):
     self.assertNotEqual(fizzbuzz.fb(), "1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100")
Beispiel #11
0
 def test_fizzbuzz(self): 
     self.assertEqual(fizzbuzz.fb(), "1, 2, fizz, 4, buzz, fizz, 7, 8, fizz, buzz, 11, fizz, 13, 14, fizzbuzz, 16, 17, fizz, 19, buzz, fizz, 22, 23, fizz, buzz, 26, fizz, 28, 29, fizzbuzz, 31, 32, fizz, 34, buzz, fizz, 37, 38, fizz, buzz, 41, fizz, 43, 44, fizzbuzz, 46, 47, fizz, 49, buzz, fizz, 52, 53, fizz, buzz, 56, fizz, 58, 59, fizzbuzz, 61, 62, fizz, 64, buzz, fizz, 67, 68, fizz, buzz, 71, fizz, 73, 74, fizzbuzz, 76, 77, fizz, 79, buzz, fizz, 82, 83, fizz, buzz, 86, fizz, 88, 89, fizzbuzz, 91, 92, fizz, 94, buzz, fizz, 97, 98, fizz, buzz")