diff --git a/fizzbuzz.py b/fizzbuzz.py new file mode 100644 index 0000000..2e380f9 --- /dev/null +++ b/fizzbuzz.py @@ -0,0 +1,15 @@ +# @File : fizzbuzz.py +# @Author: Wenyuan Gu +# @Date : 2020/1/15 + + +def fizzbuzz(n): + return 'Fizz'[n % 3 * 4:] + 'Buzz'[n % 5 * 4:] or n + + +def main(): + for i in range(1, 101): + print(fizzbuzz(i)) + +if __name__ == '__main__': + main() \ No newline at end of file diff --git a/fizzbuzz_test.py b/fizzbuzz_test.py new file mode 100644 index 0000000..132e38b --- /dev/null +++ b/fizzbuzz_test.py @@ -0,0 +1,20 @@ +# @File : fizzbuzz_test.py +# @Author: Wenyuan Gu +# @Date : 2020/1/15 + + +import pytest +from fizzbuzz import fizzbuzz + +class Test_fizzbuzz(): + def test2(self): + assert fizzbuzz(2) == 2 + def test3(self): + assert fizzbuzz(3) == 'Fizz' + def test5(self): + assert fizzbuzz(5) == 'Buzz' + def test15(self): + assert fizzbuzz(15) == 'FizzBuzz' + +if __name__ == "__main__": + pytest.main() 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!'