Witam, mam problem z wykonaniem unittestu na zrobionym przeze mnie skrypcie. Otóż gdy wykonałam unittest dla obu funkcji to na zmianę wyświetla się wykonanie obu lub jednego testu. Kombinowałam na różne sposoby, ale nic to nie dało. Bardzo proszę o pomoc.
def GiveGeomSeqElement(a1=2, factor=2, index=2):
# value of 64 elements of a geometric string with the first element 1 and a factor of 2
value = a1 * pow(factor, index - 1)
print("I")
return value
def GiveGeomSeqElementII(a1=3, factor=2, maxindex=10):
for i in range(1, maxindex):
an = GiveGeomSeqElement(a1=a1, factor=factor, index=i)
#print("element", i, "value:", an)
print("II")
return True
if __name__ == "__main__":
GiveGeomSeqElement()
GiveGeomSeqElementII()
import main
import unittest
class testMain(unittest.TestCase):
def test_GiveGeomSeqElement(self):
self.assertNotEqual(8, main.GiveGeomSeqElement(3, 2, 10))
self.assertEqual(32768, main.GiveGeomSeqElement(1, 2, 16))
self.assertEqual(-32, main.GiveGeomSeqElement(1, -2, 6))
self.assertNotEqual(1, main.GiveGeomSeqElement(1, 2, 0))
self.assertEqual(0, main.GiveGeomSeqElement(1, 0, 2))
def test_GiveGeomSeqElementII(self):
self.assertTrue(main.GiveGeomSeqElementII())
if __name__ == "__main__":
unittest.main()
- 2020-06-23 20_51_11-Ubuntu [Uruchomiona] - Oracle VM VirtualBox.png (47 KB) - ściągnięć: 20
- 2020-06-23 20_54_51-Ubuntu [Uruchomiona] - Oracle VM VirtualBox.png (61 KB) - ściągnięć: 18
- 2020-06-23 20_50_10-Ubuntu [Uruchomiona] - Oracle VM VirtualBox.png (52 KB) - ściągnięć: 29
- 2020-06-23 20_52_55-Ubuntu [Uruchomiona] - Oracle VM VirtualBox.png (53 KB) - ściągnięć: 135
- 2020-06-23 20_55_38-Ubuntu [Uruchomiona] - Oracle VM VirtualBox.png (52 KB) - ściągnięć: 96
- 2020-06-23 20_54_00-Ubuntu [Uruchomiona] - Oracle VM VirtualBox.png (51 KB) - ściągnięć: 25