I added 100 test cases, and put in the preloded code.
import codewars_test as test import random # TODO Write tests import solution # or from solution import example # test.assert_equals(actual, expected, [optional] message) @test.describe("Random test cases") def random_tests(): @test.it("Random test") def test_case(): for x in range(100): randomValue = random.randint(-1000, 1000) test.assert_equals(is_more_then_2(randomValue), randomValue > 2)
- import codewars_test as test
- import random
- # TODO Write tests
- import solution # or from solution import example
- # test.assert_equals(actual, expected, [optional] message)
@test.describe("Example")def test_group():@test.it("test case")- @test.describe("Random test cases")
- def random_tests():
- @test.it("Random test")
- def test_case():
test.assert_equals(1 + 1, 2)- for x in range(100):
- randomValue = random.randint(-1000, 1000)
- test.assert_equals(is_more_then_2(randomValue), randomValue > 2)
Added Testcases, and also made it so that it knew that 9+10=21 like from the meme.
def testFunction(n): if n == 9 + 10: return 21 #haha funny number return eval(str(n))
def test(n):return eval(n)- def testFunction(n):
- if n == 9 + 10:
- return 21 #haha funny number
- return eval(str(n))
import codewars_test as test # TODO Write tests import solution # or from solution import example # test.assert_equals(actual, expected, [optional] message) @test.describe("FixedCases") def fixedCases(): @test.it("One plus one") def testCase(): test.assert_equals(testFunction(1+1), 2) @test.it("nine plus ten") def testCase(): test.assert_equals(testFunction(9+10), 21)
- import codewars_test as test
- # TODO Write tests
- import solution # or from solution import example
- # test.assert_equals(actual, expected, [optional] message)
@test.describe("Example")def test_group():@test.it("test case")def test_case():test.assert_equals(1 + 1, 2)- @test.describe("FixedCases")
- def fixedCases():
- @test.it("One plus one")
- def testCase():
- test.assert_equals(testFunction(1+1), 2)
- @test.it("nine plus ten")
- def testCase():
- test.assert_equals(testFunction(9+10), 21)
I changed the program so it does the modulation with a while loop.
import random import time def not_even(n): pizza_time = time.ctime() while n > 1: n -= 2 if n == 0: return 'its not even', pizza_time else: return 'its still not even', pizza_time return pizza_time n = random.randint(0, 10000) print(not_even(n))
- import random
- import time
- def not_even(n):
- pizza_time = time.ctime()
if n % 2 == 0:- while n > 1:
- n -= 2
- if n == 0:
- return 'its not even', pizza_time
- else:
- return 'its still not even', pizza_time
- return pizza_time
- n = random.randint(0, 10000)
- print(not_even(n))
# TODO Write tests import solution # or from solution import example import time # test.assert_equals(actual, expected, [optional] message) @test.describe("Example") def test_group(): @test.it("test case") def test_case(): if time.ctime() == time.ctime(): test.assert_equals('its not even', 'its not even') or test.assert_equals('its still even', 'its still even')
- # TODO Write tests
- import solution # or from solution import example
- import time
- # test.assert_equals(actual, expected, [optional] message)
- @test.describe("Example")
- def test_group():
- @test.it("test case")
- def test_case():
- if time.ctime() == time.ctime():
- test.assert_equals('its not even', 'its not even') or test.assert_equals('its still even', 'its still even')
Creates a fixed test for the denominator being zero, and makes it so that when it is zero None is returned.
def division(a, b): if b == 0: return None return a / b
- def division(a, b):
- if b == 0:
- return None
- return a / b
import codewars_test as test import random # Random test cases @test.describe("Fixed tests") def fixed_tests(): test.assert_equals(division(random.randint(-1000,1000), 0), None) @test.describe("Random tests") def random_tests(): @test.it("Random tests") def random_test_cases(): for _ in range(100): a = random.randint(-1000, 1000) b = random.randint(-1000, 1000) expected = a / b test.assert_equals(division(a,b), expected)
- import codewars_test as test
- import random
- # Random test cases
- @test.describe("Fixed tests")
- def fixed_tests():
- test.assert_equals(division(random.randint(-1000,1000), 0), None)
- @test.describe("Random tests")
- def random_tests():
- @test.it("Random tests")
- def random_test_cases():
- for _ in range(100):
- a = random.randint(-1000, 1000)
- b = random.randint(-1000, 1000)
- expected = a / b
- test.assert_equals(division(a,b), expected)
I fixed the error in the test cases, and I added 99 more test cases that all are the same thing.
import codewars_test as test # TODO Write tests import solution # or from solution import example print("hi") # test.assert_equals(actual, expected, [optional] message) @test.describe("Example") def test_group(): @test.it("test case") def test_case(): test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2)
- import codewars_test as test
- # TODO Write tests
- import solution # or from solution import example
- print("hi")
- # test.assert_equals(actual, expected, [optional] message)
- @test.describe("Example")
- def test_group():
- @test.it("test case")
- def test_case():
test.assert_equals(1 + 1, 2)''- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)