|
| 1 | +print("\n***assert_equal(a, b)***\n") |
| 2 | +def assert_equal(a, b): |
| 3 | + assert a == b, "({}) is not equal ({})".format(a,b) |
| 4 | + print("({}) is equal ({})".format(a,b)) |
| 5 | +# if a == b: |
| 6 | +# print("({}) is equal ({})".format(a,b)) |
| 7 | +# return True |
| 8 | +# else: |
| 9 | +# print("({}) is not equal ({})".format(a,b)) |
| 10 | +# return False |
| 11 | + |
| 12 | + |
| 13 | +def test(a,b): |
| 14 | + try: |
| 15 | + assert_equal(a,b) |
| 16 | + except BaseException as e: |
| 17 | + print("Exception caught: {}".format(e)) |
| 18 | + |
| 19 | +test(1,1) |
| 20 | +test(1,-1) |
| 21 | +test("qwe","qwe") |
| 22 | +test("qwe","Qwe") |
| 23 | +test([1,2,3],[1,2,3]) |
| 24 | +test(True,1) |
| 25 | +test(0,False) |
| 26 | +test(False,1) |
| 27 | +test("",0) |
| 28 | +test("",None) |
| 29 | +test(0,None) |
| 30 | + |
| 31 | +try: |
| 32 | + assert_equal("", ) |
| 33 | +except BaseException as e: |
| 34 | + print("Exception caught: {}".format(e)) |
| 35 | + |
| 36 | +try: |
| 37 | + assert_equal(1,) |
| 38 | +except BaseException as e: |
| 39 | + print("Exception caught: {}".format(e)) |
| 40 | + |
| 41 | +try: |
| 42 | + assert_equal() |
| 43 | +except BaseException as e: |
| 44 | + print("Exception caught: {}".format(e)) |
| 45 | + |
| 46 | +try: |
| 47 | + assert_equal(1) |
| 48 | +except BaseException as e: |
| 49 | + print("Exception caught: {}".format(e)) |
| 50 | + |
| 51 | +try: |
| 52 | + assert_equal(1,1,1) |
| 53 | +except BaseException as e: |
| 54 | + print("Exception caught: {}".format(e)) |
| 55 | + |
| 56 | + |
| 57 | +print("\n***assert_not_equal(a, b)***\n") |
| 58 | +def assert_not_equal(a, b): |
| 59 | + assert a != b, "({}) is equal ({})".format(a,b) |
| 60 | + print("({}) is not equal ({})".format(a,b)) |
| 61 | + |
| 62 | + |
| 63 | +def test2(a,b): |
| 64 | + try: |
| 65 | + assert_not_equal(a,b) |
| 66 | + except BaseException as e: |
| 67 | + print("Exception caught: {}".format(e)) |
| 68 | + |
| 69 | +test2(1,1) |
| 70 | +test2(1,-1) |
| 71 | +test2(True,1) |
| 72 | +test2(False,1) |
| 73 | +test2(0,None) |
| 74 | + |
| 75 | +try: |
| 76 | + assert_not_equal() |
| 77 | +except BaseException as e: |
| 78 | + print("Exception caught: {}".format(e)) |
| 79 | + |
| 80 | +try: |
| 81 | + assert_not_equal(1,1,1) |
| 82 | +except BaseException as e: |
| 83 | + print("Exception caught: {}".format(e)) |
| 84 | + |
| 85 | + |
| 86 | +print("\n***assert_true(x)***\n") |
| 87 | +def assert_true(x): |
| 88 | + assert x, "({}) not True".format(x) |
| 89 | + print("({}) True".format(x)) |
| 90 | + |
| 91 | + |
| 92 | +def test3(x): |
| 93 | + try: |
| 94 | + assert_true(x) |
| 95 | + except BaseException as e: |
| 96 | + print("Exception caught: {}".format(e)) |
| 97 | + |
| 98 | +test3(1) |
| 99 | +test3(0) |
| 100 | +test3(2) |
| 101 | +test3(False) |
| 102 | +test3(True) |
| 103 | +test3(1 is 1) |
| 104 | +test3("") |
| 105 | +test3(None) |
| 106 | + |
| 107 | +try: |
| 108 | + assert_true(2 is not "A") |
| 109 | +except BaseException as e: |
| 110 | + print("Exception caught: {}".format(e)) |
| 111 | + |
| 112 | +try: |
| 113 | + assert_true(0,0) |
| 114 | +except BaseException as e: |
| 115 | + print("Exception caught: {}".format(e)) |
| 116 | + |
| 117 | + |
| 118 | +# assert_false(x) |
| 119 | +print("\n***assert_false(x)***\n") |
| 120 | +def assert_false(x): |
| 121 | + assert not x , "({}) not False".format(x) |
| 122 | + print("({}) False".format(x)) |
| 123 | + |
| 124 | + |
| 125 | +def test4(x): |
| 126 | + try: |
| 127 | + assert_false(x) |
| 128 | + except BaseException as e: |
| 129 | + print("Exception caught: {}".format(e)) |
| 130 | + |
| 131 | +test4(1) |
| 132 | +test4(0) |
| 133 | +test4(2) |
| 134 | +test4("") |
| 135 | +test4(None) |
| 136 | +test4(False) |
| 137 | +test4(True) |
| 138 | +test4(1 is 1) |
| 139 | + |
| 140 | +try: |
| 141 | + assert_false(2 is "A") |
| 142 | +except BaseException as e: |
| 143 | + print("Exception caught: {}".format(e)) |
| 144 | + |
| 145 | +try: |
| 146 | + assert_false(0,0) |
| 147 | +except BaseException as e: |
| 148 | + print("Exception caught: {}".format(e)) |
| 149 | + |
| 150 | +# assert_is(a, b) |
| 151 | + |
| 152 | +print("\n***assert_is(a, b)***\n") |
| 153 | +def assert_is(a, b): |
| 154 | + assert a is b , "({}) is not ({})".format(a,b) |
| 155 | + print("({}) is ({})".format(a,b)) |
| 156 | + |
| 157 | + |
| 158 | +def test5(a,b): |
| 159 | + try: |
| 160 | + assert_is(a, b) |
| 161 | + except BaseException as e: |
| 162 | + print("Exception caught: {}".format(e)) |
| 163 | + |
| 164 | +test5(1,1) |
| 165 | +test5(1,-1) |
| 166 | +test5([1,2,3],[1,2,3]) |
| 167 | +test5(True,1) |
| 168 | +test5(False,1 is not 1) |
| 169 | +test5("",None) |
| 170 | + |
| 171 | +try: |
| 172 | + assert_is() |
| 173 | +except BaseException as e: |
| 174 | + print("Exception caught: {}".format(e)) |
| 175 | + |
| 176 | +try: |
| 177 | + assert_is(1,1,1) |
| 178 | +except BaseException as e: |
| 179 | + print("Exception caught: {}".format(e)) |
| 180 | + |
| 181 | +# assert_is_not(a, b) |
| 182 | +print("\n***assert_is_not(a, b)***\n") |
| 183 | +def assert_is_not(a, b): |
| 184 | + assert a is not b , "({}) is ({})".format(a,b) |
| 185 | + print("({}) is not ({})".format(a,b)) |
| 186 | + |
| 187 | + |
| 188 | +def test6(a,b): |
| 189 | + try: |
| 190 | + assert_is_not(a, b) |
| 191 | + except BaseException as e: |
| 192 | + print("Exception caught: {}".format(e)) |
| 193 | + |
| 194 | +test6(1,1) |
| 195 | +test6(1,-1) |
| 196 | +test6(True,1) |
| 197 | +test6(False,1 is not 1) |
| 198 | +test6("",None) |
| 199 | + |
| 200 | +try: |
| 201 | + assert_is_not() |
| 202 | +except BaseException as e: |
| 203 | + print("Exception caught: {}".format(e)) |
| 204 | + |
| 205 | +try: |
| 206 | + assert_is_not(a,b,c) |
| 207 | +except BaseException as e: |
| 208 | + print("Exception caught: {}".format(e)) |
| 209 | + |
| 210 | +# assert_is_none(x) |
| 211 | +print("\n***assert_is_none(x)***\n") |
| 212 | +def assert_is_none(x): |
| 213 | + assert x is None , "({}) is not None".format(x) |
| 214 | + print("({}) is None".format(x)) |
| 215 | + |
| 216 | + |
| 217 | +def test7(x): |
| 218 | + try: |
| 219 | + assert_is_none(x) |
| 220 | + except BaseException as e: |
| 221 | + print("Exception caught: {}".format(e)) |
| 222 | + |
| 223 | +test7(1) |
| 224 | +test7(0) |
| 225 | +test7(True) |
| 226 | +test7([]) |
| 227 | +test7(None) |
| 228 | +test7("") |
| 229 | + |
| 230 | +try: |
| 231 | + assert_is_none() |
| 232 | +except BaseException as e: |
| 233 | + print("Exception caught: {}".format(e)) |
| 234 | + |
| 235 | +try: |
| 236 | + assert_is_none(a,b,c) |
| 237 | +except BaseException as e: |
| 238 | + print("Exception caught: {}".format(e)) |
| 239 | + |
| 240 | +# assert_is_not_none(x) |
| 241 | +print("\n***assert_is_not_none(x)***\n") |
| 242 | +def assert_is_not_none(x): |
| 243 | + assert x is not None , "({}) is None".format(x) |
| 244 | + print("({}) is not None".format(x)) |
| 245 | + |
| 246 | + |
| 247 | +def test8(x): |
| 248 | + try: |
| 249 | + assert_is_not_none(x) |
| 250 | + except BaseException as e: |
| 251 | + print("Exception caught: {}".format(e)) |
| 252 | + |
| 253 | +test8(1) |
| 254 | +test8(0) |
| 255 | +test8(True) |
| 256 | +test8([]) |
| 257 | +test8(None) |
| 258 | +test8("") |
| 259 | + |
| 260 | +try: |
| 261 | + assert_is_not_none() |
| 262 | +except BaseException as e: |
| 263 | + print("Exception caught: {}".format(e)) |
| 264 | + |
| 265 | +try: |
| 266 | + assert_is_not_none(a,b,c) |
| 267 | +except BaseException as e: |
| 268 | + print("Exception caught: {}".format(e)) |
| 269 | + |
| 270 | +# assert_in(a, b) |
| 271 | +print("\n***assert_in(a, b)***\n") |
| 272 | +def assert_in(a, b): |
| 273 | + assert a in b , "({}) not in ({})".format(a,b) |
| 274 | + print("({}) in ({})".format(a,b)) |
| 275 | + |
| 276 | + |
| 277 | +def test9(a,b): |
| 278 | + try: |
| 279 | + assert_in(a, b) |
| 280 | + except BaseException as e: |
| 281 | + print("Exception caught: {}".format(e)) |
| 282 | + |
| 283 | +test9(1,[1]) |
| 284 | +test9(1,[-1,1,0,2,3]) |
| 285 | +test9([1,2],[1,2,3]) |
| 286 | +test9([1,2],[[1,2,3],[1,2]]) |
| 287 | +test9(1,[[1,2,3],[1,2]]) |
| 288 | +test9("tr","control") |
| 289 | +test9(None,[]) |
| 290 | + |
| 291 | +try: |
| 292 | + assert_in(None,["",0, False]) |
| 293 | +except BaseException as e: |
| 294 | + print("Exception caught: {}".format(e)) |
| 295 | + |
| 296 | +try: |
| 297 | + assert_in(a, b) |
| 298 | +except BaseException as e: |
| 299 | + print("Exception caught: {}".format(e)) |
| 300 | + |
| 301 | +try: |
| 302 | + assert_in(1,1,1) |
| 303 | +except BaseException as e: |
| 304 | + print("Exception caught: {}".format(e)) |
| 305 | + |
| 306 | +# assert_not_in(a, b) |
| 307 | +print("\n***assert_not_in(a, b)***\n") |
| 308 | +def assert_not_in(a, b): |
| 309 | + assert a not in b , "({}) in ({})".format(a,b) |
| 310 | + print("({}) not in ({})".format(a,b)) |
| 311 | + |
| 312 | + |
| 313 | +def test10(a,b): |
| 314 | + try: |
| 315 | + assert_not_in(a, b) |
| 316 | + except BaseException as e: |
| 317 | + print("Exception caught: {}".format(e)) |
| 318 | + |
| 319 | +test10(1,[1]) |
| 320 | +test10(1,[-1,1,0,2,3]) |
| 321 | +test10([1,2],[1,2,3]) |
| 322 | +test10([1,2],[[1,2,3],[1,2]]) |
| 323 | +test10(1,[[1,2,3],[1,2]]) |
| 324 | +test10("tr","control") |
| 325 | +test10(None,[]) |
| 326 | + |
| 327 | +try: |
| 328 | + assert_not_in(None,["",0, False]) |
| 329 | +except BaseException as e: |
| 330 | + print("Exception caught: {}".format(e)) |
| 331 | + |
| 332 | +try: |
| 333 | + assert_not_in(a, b) |
| 334 | +except BaseException as e: |
| 335 | + print("Exception caught: {}".format(e)) |
| 336 | + |
| 337 | +try: |
| 338 | + assert_not_in(1,1,1) |
| 339 | +except BaseException as e: |
| 340 | + print("Exception caught: {}".format(e)) |
| 341 | + |
| 342 | + |
| 343 | +# in commit don't forget add comment |
| 344 | +# __init__.py |
| 345 | +# andrey.txt |
| 346 | +# hash_my_name.py |
| 347 | + |
| 348 | +# filipovski |
| 349 | +# AyratSaubanov |
0 commit comments