From 8a667b56e73e6a3ba26c3c5feec74d89f34e9c09 Mon Sep 17 00:00:00 2001 From: haoransun94 Date: Wed, 15 Jan 2020 13:10:43 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=96=B0=E5=A2=9EfizzBuzz=5Ftest?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fizzbuzz_test.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 fizzbuzz_test.py diff --git a/fizzbuzz_test.py b/fizzbuzz_test.py new file mode 100644 index 0000000..fda65d3 --- /dev/null +++ b/fizzbuzz_test.py @@ -0,0 +1,26 @@ +import unittest + + +class FizzBuzz(object): + @classmethod + def read(cls, num): + res = "" + if num % 3 == 0: + res += "Fizz" + if num % 5 == 0: + res += "Buzz" + if res == "": + return str(num) + return res + + +class MyTestCase(unittest.TestCase): + def test_something(self): + self.assertEqual(FizzBuzz.read(1), "1") + self.assertEqual(FizzBuzz.read(3), "Fizz") + self.assertEqual(FizzBuzz.read(5), "Buzz") + self.assertEqual(FizzBuzz.read(15), "FizzBuzz") + + +if __name__ == '__main__': + unittest.main()