From e501e3a824b416d13f207294dc450eafb01001c5 Mon Sep 17 00:00:00 2001 From: Ojo Timilehin Joseph Date: Mon, 20 Dec 2021 23:01:00 +0100 Subject: [PATCH 1/2] [Fix] - edge cases --- .../tests/7-base_geometry.txt | 142 +++++++----------- 1 file changed, 55 insertions(+), 87 deletions(-) diff --git a/0x0A-python-inheritance/tests/7-base_geometry.txt b/0x0A-python-inheritance/tests/7-base_geometry.txt index f24bb73..4f551b1 100644 --- a/0x0A-python-inheritance/tests/7-base_geometry.txt +++ b/0x0A-python-inheritance/tests/7-base_geometry.txt @@ -1,122 +1,90 @@ -The ``7-base_geometry`` module -============================== +Test for BaseGeometry Class +========================================== -Using ``BaseGeometry`` ----------------------- - -Importing class from the module: +Import the class: >>> BaseGeometry = __import__('7-base_geometry').BaseGeometry +----------------------------- +----------------------------- + No arguments -Trying to print the area - >>> bg = BaseGeometry() - >>> bg.area() - Traceback (most recent call last): - ... - Exception: area() is not implemented + >>> obj = BaseGeometry() +----------------------------- +----------------------------- + One arg -Trying to pass a non-integer argument - >>> bg = BaseGeometry() - >>> bg.integer_validator("name", "5") + >>> obj_1 = BaseGeometry(1) Traceback (most recent call last): - ... - TypeError: name must be an integer + TypeError: object() takes no parameters +----------------------------- +----------------------------- + Two args -Trying to pass a boolean value - >>> bg = BaseGeometry() - >>> bg.integer_validator("name", True) + >>> obj_2 = BaseGeometry(1, 1) Traceback (most recent call last): - ... - TypeError: name must be an integer + TypeError: object() takes no parameters +----------------------------- +----------------------------- + Dir -Trying to pass a negative value - >>> bg = BaseGeometry() - >>> bg.integer_validator("name", -5) - Traceback (most recent call last): - ... - ValueError: name must be greater than 0 + >>> 'area' in dir(obj) + True + >>> 'integer_validator' in dir(obj) + True +----------------------------- +----------------------------- + Area error -Trying to pass a zero value - >>> bg = BaseGeometry() - >>> bg.integer_validator("name", 0) + >>> obj.area() Traceback (most recent call last): - ... - ValueError: name must be greater than 0 - + Exception: area() is not implemented -Passing a positive value - >>> bg = BaseGeometry() - >>> bg.integer_validator("name", 5) +----------------------------- +----------------------------- + integer_validator + >>> obj.integer_validator() + Traceback (most recent call last): + TypeError: integer_validator() missing 2 required positional arguments: 'name' and 'value' -Passing one argument to integer_validator - >>> bg = BaseGeometry() - >>> bg.integer_validator("name") + >>> obj.integer_validator(0) Traceback (most recent call last): - ... TypeError: integer_validator() missing 1 required positional argument: 'value' -Integer_validator with no arguments - >>> bg = BaseGeometry() - >>> bg.integer_validator() + >>> obj.integer_validator(0, 0, 0, 0) Traceback (most recent call last): - ... - TypeError: integer_validator() missing 2 required positional arguments: 'name' and 'value' - + TypeError: integer_validator() takes 3 positional arguments but 5 were given -Passing three arguments to integer_validator - >>> bg = BaseGeometry() - >>> bg.integer_validator("name", 1, 2) + >>> obj.integer_validator("name",None) Traceback (most recent call last): - ... - TypeError: integer_validator() takes 3 positional arguments but 4 were given + TypeError: name must be an integer + >>> obj.integer_validator(1, 1) -Passing one argument to area method - >>> bg = BaseGeometry() - >>> bg.area(5) - Traceback (most recent call last): - ... - TypeError: area() takes 1 positional argument but 2 were given + >>> obj.integer_validator("str", True) + + >>> obj.integer_validator(1, True) -Passing two arguments to area method - >>> bg = BaseGeometry() - >>> bg.area(5, 5) + >>> obj.integer_validator(1, []) Traceback (most recent call last): - ... - TypeError: area() takes 1 positional argument but 3 were given + TypeError: 1 must be an integer -Passing tuple to method - >>> bg = BaseGeometry() - >>> bg.integer_validator("age", (4,)) + >>> obj.integer_validator(1, 'hbtn') Traceback (most recent call last): - ... - TypeError: age must be an integer + TypeError: 1 must be an integer + >>> obj.integer_validator({}, 1) + + >>> obj.integer_validator('julien', 2) -Passing list to method - >>> bg = BaseGeometry() - >>> bg.integer_validator("age", [3]) + >>> obj.integer_validator('julien', 0) Traceback (most recent call last): - ... - TypeError: age must be an integer - - -Passing dict to method - >>> bg = BaseGeometry() - >>> bg.integer_validator("age", {3, 4}) - Traceback (most recent call last): - ... - TypeError: age must be an integer - + ValueError: julien must be greater than 0 -Passing None to method - >>> bg = BaseGeometry() - >>> bg.integer_validator("age", None) + >>> obj.integer_validator('julien', -2) Traceback (most recent call last): - ... - TypeError: age must be an integer + ValueError: julien must be greater than 0 From 45c9c3d4e6f9e99071a4ddfed7486c0ce5eab88e Mon Sep 17 00:00:00 2001 From: Ojo Timilehin Joseph Date: Mon, 20 Dec 2021 23:03:24 +0100 Subject: [PATCH 2/2] Delete 7-base_geometry.txt --- .../tests/7-base_geometry.txt | 90 ------------------- 1 file changed, 90 deletions(-) delete mode 100644 0x0A-python-inheritance/tests/7-base_geometry.txt diff --git a/0x0A-python-inheritance/tests/7-base_geometry.txt b/0x0A-python-inheritance/tests/7-base_geometry.txt deleted file mode 100644 index 4f551b1..0000000 --- a/0x0A-python-inheritance/tests/7-base_geometry.txt +++ /dev/null @@ -1,90 +0,0 @@ -Test for BaseGeometry Class -========================================== - -Import the class: - >>> BaseGeometry = __import__('7-base_geometry').BaseGeometry - ------------------------------ ------------------------------ - No arguments - - >>> obj = BaseGeometry() - ------------------------------ ------------------------------ - One arg - - >>> obj_1 = BaseGeometry(1) - Traceback (most recent call last): - TypeError: object() takes no parameters - ------------------------------ ------------------------------ - Two args - - >>> obj_2 = BaseGeometry(1, 1) - Traceback (most recent call last): - TypeError: object() takes no parameters - ------------------------------ ------------------------------ - Dir - - >>> 'area' in dir(obj) - True - >>> 'integer_validator' in dir(obj) - True - ------------------------------ ------------------------------ - Area error - - >>> obj.area() - Traceback (most recent call last): - Exception: area() is not implemented - ------------------------------ ------------------------------ - integer_validator - - >>> obj.integer_validator() - Traceback (most recent call last): - TypeError: integer_validator() missing 2 required positional arguments: 'name' and 'value' - - >>> obj.integer_validator(0) - Traceback (most recent call last): - TypeError: integer_validator() missing 1 required positional argument: 'value' - - >>> obj.integer_validator(0, 0, 0, 0) - Traceback (most recent call last): - TypeError: integer_validator() takes 3 positional arguments but 5 were given - - >>> obj.integer_validator("name",None) - Traceback (most recent call last): - TypeError: name must be an integer - - >>> obj.integer_validator(1, 1) - - >>> obj.integer_validator("str", True) - - >>> obj.integer_validator(1, True) - - >>> obj.integer_validator(1, []) - Traceback (most recent call last): - TypeError: 1 must be an integer - - >>> obj.integer_validator(1, 'hbtn') - Traceback (most recent call last): - TypeError: 1 must be an integer - - >>> obj.integer_validator({}, 1) - - >>> obj.integer_validator('julien', 2) - - >>> obj.integer_validator('julien', 0) - Traceback (most recent call last): - ValueError: julien must be greater than 0 - - >>> obj.integer_validator('julien', -2) - Traceback (most recent call last): - ValueError: julien must be greater than 0