本文整理汇总了Python中app.FizzBuzz类的典型用法代码示例。如果您正苦于以下问题:Python FizzBuzz类的具体用法?Python FizzBuzz怎么用?Python FizzBuzz使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FizzBuzz类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_run
def test_run(self):
output = StringIO()
app = FizzBuzz()
app.run(100, output)
self.failIf(len(output.getvalue().splitlines()) != 100)
示例2: test_run
def test_run(self):
output = StringIO()
app = FizzBuzz()
app.run(100, output)
op = len(output.getvalue().splitlines())
print "Outputlines: " + str(op)
self.failIf(op != 99)
示例3: test_three
def test_three(self):
app = FizzBuzz()
output = StringIO()
app.run(100, output)
self.failIf(output.getvalue().splitlines().count("Fizz") != 26)
self.failIf(output.getvalue().splitlines().count("Buzz") != 13)
self.failIf(output.getvalue().splitlines().count("FizzBuzz") != 6)
示例4: test_prime
def test_prime(self):
app = FizzBuzz()
output = StringIO()
app.run(100, output)
lista = output.getvalue().splitlines()
primecount = ['is a prime' in x for x in lista]
self.failIf(primecount.count(True) !=25)
示例5: test_V2_primes
def test_V2_primes(self):
app = FizzBuzz()
self.failIf(app.calc(7) != "7 is a prime")
self.failIf(app.calc(11) != "11 is a prime")
self.failIf(app.calc(19) != "19 is a prime")
self.failIf(app.calc(23) != "23 is a prime")
self.failIf(app.calc(31) != "31 is a prime")
示例6: test_two
def test_two(self):
app = FizzBuzz()
output = StringIO()
app.run(50, output)
# print output.getvalue().splitlines()[2]
self.failIf(output.getvalue().splitlines()[0] != "1")
self.failIf(output.getvalue().splitlines()[5] != "Fizz")
self.failIf(output.getvalue().splitlines()[9] != "Buzz")
self.failIf(output.getvalue().splitlines()[14] != "FizzBuzz")
self.failIf(output.getvalue().splitlines()[44] != "FizzBuzz")
示例7: test_buzz
def test_buzz(self):
app = FizzBuzz()
self.failIf(app.calc(10) != "Buzz")
self.failIf(app.calc(100) != "Buzz")
示例8: test_nonprimes
def test_nonprimes(self):
app = FizzBuzz()
f = open('nonprimes.txt', 'r')
for line in f:
self.failIf(app.is_prime(int(line)) != False)
示例9: test_fizz
def test_fizz(self):
app = FizzBuzz()
self.failIf(app.calc(6) != "Fizz")
self.failIf(app.calc(18) != "Fizz")
self.failIf(app.calc(99) != "Fizz")
示例10: test_primes
def test_primes(self):
app = FizzBuzz()
for i in (2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97):
self.failIf(app.calc(i) != "is a prime")
示例11: test_five
def test_five(self):
app = FizzBuzz()
self.failIf(app.calc(15) != "FizzBuzz")
self.failIf(app.calc(30) != "FizzBuzz")
示例12: test_three
def test_three(self):
app = FizzBuzz()
self.failIf(app.calc(6) != "Fizz")
self.failIf(app.calc(9) != "Fizz")
示例13: test_fizz
def test_fizz(self):
app=FizzBuzz()
self.failIf(app.calc(9) = "Fizz")
示例14: test_5_7
def test_5_7(self):
app = FizzBuzz()
self.failIf(app.calc(10) != "Buzz")
self.failIf(app.calc(20) != "Buzz")
示例15: test_two
def test_two(self):
app = FizzBuzz()
self.failIf(app.calc(6) != "Fizz")