From ef3bacb551914ba5d9f760ab99bfb3cf0177fff0 Mon Sep 17 00:00:00 2001 From: ppomelo <327881179@qq.com> Date: Tue, 14 Jan 2020 23:40:28 +0800 Subject: [PATCH 1/5] fizzbuzz --- fizzbuzz.py | 16 ++++++++++++++++ fizzbuzz_test.py | 16 ++++++++++++++++ helloworld.py | 2 -- helloworld_test.py | 5 ----- 4 files changed, 32 insertions(+), 7 deletions(-) create mode 100644 fizzbuzz.py create mode 100644 fizzbuzz_test.py delete mode 100644 helloworld.py delete mode 100644 helloworld_test.py diff --git a/fizzbuzz.py b/fizzbuzz.py new file mode 100644 index 0000000..1f0bed7 --- /dev/null +++ b/fizzbuzz.py @@ -0,0 +1,16 @@ +def FizzBuzz(num): + + if num % 3 == 0 and num % 5 == 0: + return 'FizzBuzz' + + if num % 3 == 0: + return 'Fizz' + + if num % 5 == 0: + return 'Buzz' + + return str(num) + +if __name__ == '__main__': + for i in range(1, 101): + print FizzBuzz(i) \ No newline at end of file diff --git a/fizzbuzz_test.py b/fizzbuzz_test.py new file mode 100644 index 0000000..3fe5655 --- /dev/null +++ b/fizzbuzz_test.py @@ -0,0 +1,16 @@ +import unittest +from fizzbuzz import FizzBuzz + +class test_fb(unittest.TestCase): + + def test_default_case(self): + self.assertEqual(FizzBuzz(1), '1') + + def test_fizz(self): + self.assertEqual(FizzBuzz(6), 'Fizz') + + def test_buzz(self): + self.assertEqual(FizzBuzz(10), 'Buzz') + + def test_fizzbuzz(self): + self.assertEqual(FizzBuzz(30), 'FizzBuzz') \ No newline at end of file diff --git a/helloworld.py b/helloworld.py deleted file mode 100644 index 449b948..0000000 --- a/helloworld.py +++ /dev/null @@ -1,2 +0,0 @@ -def get_greetings(): - return 'Hello World!' diff --git a/helloworld_test.py b/helloworld_test.py deleted file mode 100644 index 4c27dfe..0000000 --- a/helloworld_test.py +++ /dev/null @@ -1,5 +0,0 @@ -from helloworld import get_greetings - - -def test_get_helloworld(): - assert get_greetings() == 'Hello World!' From ba455e2dd24dc05ac46e818af9f71088b548cbd9 Mon Sep 17 00:00:00 2001 From: ppomelo <327881179@qq.com> Date: Wed, 15 Jan 2020 00:01:05 +0800 Subject: [PATCH 2/5] fix python 3 print style for passing ci build --- fizzbuzz.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fizzbuzz.py b/fizzbuzz.py index 1f0bed7..846aa1f 100644 --- a/fizzbuzz.py +++ b/fizzbuzz.py @@ -13,4 +13,4 @@ def FizzBuzz(num): if __name__ == '__main__': for i in range(1, 101): - print FizzBuzz(i) \ No newline at end of file + print(FizzBuzz(i)) \ No newline at end of file From d48635ef0b61850b02b99eea3e83e144cc496fc5 Mon Sep 17 00:00:00 2001 From: ppomelo <327881179@qq.com> Date: Wed, 15 Jan 2020 00:04:07 +0800 Subject: [PATCH 3/5] delete whitespace in blank line for passing pystyle test --- fizzbuzz.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fizzbuzz.py b/fizzbuzz.py index 846aa1f..7232058 100644 --- a/fizzbuzz.py +++ b/fizzbuzz.py @@ -5,7 +5,7 @@ def FizzBuzz(num): if num % 3 == 0: return 'Fizz' - + if num % 5 == 0: return 'Buzz' From e6ce8a4488681f04761b0fec2d393a427848a51e Mon Sep 17 00:00:00 2001 From: ppomelo <327881179@qq.com> Date: Wed, 15 Jan 2020 00:12:14 +0800 Subject: [PATCH 4/5] fix py style --- fizzbuzz.py | 7 ++++--- fizzbuzz_test.py | 10 +++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/fizzbuzz.py b/fizzbuzz.py index 7232058..dfa58d9 100644 --- a/fizzbuzz.py +++ b/fizzbuzz.py @@ -1,4 +1,4 @@ -def FizzBuzz(num): +def fizz_buzz(num): if num % 3 == 0 and num % 5 == 0: return 'FizzBuzz' @@ -8,9 +8,10 @@ def FizzBuzz(num): if num % 5 == 0: return 'Buzz' - + return str(num) + if __name__ == '__main__': for i in range(1, 101): - print(FizzBuzz(i)) \ No newline at end of file + print(fizz_buzz(i)) diff --git a/fizzbuzz_test.py b/fizzbuzz_test.py index 3fe5655..1e231c3 100644 --- a/fizzbuzz_test.py +++ b/fizzbuzz_test.py @@ -1,16 +1,16 @@ import unittest -from fizzbuzz import FizzBuzz +from fizzbuzz import fizz_buzz class test_fb(unittest.TestCase): def test_default_case(self): - self.assertEqual(FizzBuzz(1), '1') + self.assertEqual(fizz_buzz(1), '1') def test_fizz(self): - self.assertEqual(FizzBuzz(6), 'Fizz') + self.assertEqual(fizz_buzz(6), 'Fizz') def test_buzz(self): - self.assertEqual(FizzBuzz(10), 'Buzz') + self.assertEqual(fizz_buzz(10), 'Buzz') def test_fizzbuzz(self): - self.assertEqual(FizzBuzz(30), 'FizzBuzz') \ No newline at end of file + self.assertEqual(fizz_buzz(30), 'FizzBuzz') \ No newline at end of file From 9a6df744ebbd7e1839d4be774657f9bd79beacf6 Mon Sep 17 00:00:00 2001 From: ppomelo <327881179@qq.com> Date: Wed, 15 Jan 2020 00:15:27 +0800 Subject: [PATCH 5/5] fix py style --- fizzbuzz_test.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fizzbuzz_test.py b/fizzbuzz_test.py index 1e231c3..3c9c347 100644 --- a/fizzbuzz_test.py +++ b/fizzbuzz_test.py @@ -1,6 +1,7 @@ import unittest from fizzbuzz import fizz_buzz + class test_fb(unittest.TestCase): def test_default_case(self): @@ -8,9 +9,9 @@ def test_default_case(self): def test_fizz(self): self.assertEqual(fizz_buzz(6), 'Fizz') - + def test_buzz(self): self.assertEqual(fizz_buzz(10), 'Buzz') def test_fizzbuzz(self): - self.assertEqual(fizz_buzz(30), 'FizzBuzz') \ No newline at end of file + self.assertEqual(fizz_buzz(30), 'FizzBuzz')