1def no_it_isnt(list):
2 result = []
3 for element in list:
4 if type(element) is str:
5 result.append(element[::-1])
6 elif type(element) == bool :
7 result.append(~element)
8 elif type(element) in (int,float):
9 result.append(-element)
10 return result
FFFF.
======================================================================
FAIL: test_bool (test.TestOpposite)
Test with a bool.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 23, in test_bool
self.assertEqual(no_it_isnt([True, False]), [True, False])
AssertionError: Lists differ: [-2, -1] != [True, False]
First differing element 0:
-2
True
- [-2, -1]
+ [True, False]
======================================================================
FAIL: test_float (test.TestOpposite)
Test with a float.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 19, in test_float
self.assertEqual(no_it_isnt([6.66, 0.0]), [0.0, -6.66])
AssertionError: Lists differ: [-6.66, -0.0] != [0.0, -6.66]
First differing element 0:
-6.66
0.0
- [-6.66, -0.0]
+ [0.0, -6.66]
======================================================================
FAIL: test_int (test.TestOpposite)
Test with an integer.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 11, in test_int
self.assertEqual(no_it_isnt([1, 2]), [-2, -1])
AssertionError: Lists differ: [-1, -2] != [-2, -1]
First differing element 0:
-1
-2
- [-1, -2]
+ [-2, -1]
======================================================================
FAIL: test_mixed (test.TestOpposite)
Test with a long mixed content of types.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 33, in test_mixed
self.assertEqual(no_it_isnt([1, 1.2, True, 'string']), ['gnirts', False, -1.2, -1])
AssertionError: Lists differ: [-1, -1.2, -2, 'gnirts'] != ['gnirts', False, -1.2, -1]
First differing element 0:
-1
'gnirts'
- [-1, -1.2, -2, 'gnirts']
+ ['gnirts', False, -1.2, -1]
----------------------------------------------------------------------
Ran 5 tests in 0.001s
FAILED (failures=4)
19.10.2023 16:43
19.10.2023 16:43
19.10.2023 16:44