Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pytest
- def inc(x):
- return x + 1
- def test_str_1():
- # Check length of string for even
- str = "By"
- assert len(str) % 2 == 0, "length of string is odd"
- def test_str_2():
- # Check length of string for odd
- str = "Hello"
- assert len(str) % 2 != 0, "length of string is even"
- def test_str_3(param):
- # Check length of string for whole division by param
- str = "Hello"
- try:
- assert len(str) % param == 0, f"length of string is not divided by {param} whole"
- except ZeroDivisionError:
- pass
- def test_set_1():
- # Check length of set for even
- set = {0, 1, 2, 3}
- assert len(set) % 2 == 0, "length of set is odd"
- def test_set_2():
- # Check length of set for odd
- set = {0, 1, 2, 3, 4}
- assert len(set) % 2 != 0, "length of set is even"
- def test_set_3(param):
- # Check length of set for whole division by param
- set = {0, 1, 2, 3, 4, 5}
- try:
- assert len(set) % param == 0, f"length of string is not divided by {param} whole"
- except ZeroDivisionError:
- pass
- test_str_1()
- test_str_2()
- test_str_3(0)
- test_set_1()
- test_set_2()
- test_set_3(0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement