Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Assertion Error
#1
Hello everyone,
I've got problem with assertion. It seems that it should work, but after running the program I receive AssertionError. Do you have any idea why and how I can fix it/modify declaration of classes? Think
This is my code:
class Figure1:
    def __init__(self, x, y, z):
        self._x = x
        self._y = y
        self._z = z
    @property
    def area(self):
        return (self._x + self._y) * self._z / 2
class Figure2(Figure1):
    def __init__(self, x, z):
        super().__init__(x=x, y=x, z=z)
class Figure3(Figure2):
    @property
    def circumference(self):
        return self._x * 4

class Figure4(Figure2):

    def __init__(self, x, y):
        super().__init__(x=x,z=y)
    @property
    def circumference(self):
        return 2 * self._x + 2 * self._z

class Figure5(Figure4, Figure3):

    def __init__(self, x):
        super().__init__(x=x, y=x)

a = Figure5(9).area
print(a)
b = Figure5(9).circumference
print(b)
if __name__ == "__main__":
    Figure5.x = 9
    assert Figure5.circumference == 36
    assert Figure5.area == 81


and the error:
Error:
81.0 Traceback (most recent call last): 36 line 37, in <module> assert Figure5.circumference == 36 AssertionError Process finished with exit code 1
Reply


Messages In This Thread
Assertion Error - by Mateoo - Jan-20-2019, 02:20 PM
RE: Assertion Error - by ichabod801 - Jan-20-2019, 03:55 PM
RE: Assertion Error - by stullis - Jan-20-2019, 03:59 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  opencv on mac: Assertion Failed RandomCoder 0 1,701 Feb-16-2020, 06:17 PM
Last Post: RandomCoder
  Test Case Assertion Error moga2003 10 5,632 Mar-18-2019, 01:06 AM
Last Post: moga2003
  error: (-215:Assertion failed) gkiller007 1 8,715 Jan-04-2019, 04:27 AM
Last Post: stullis

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020