7
7
import sys
8
8
from operator import add , floordiv , mul , pow , sub , truediv
9
9
10
- import pandas as pd
11
10
import pytest
12
11
13
12
from task_2 import Array1D , IncompatibleArrayOperationError , InvalidEntryError
@@ -28,7 +27,7 @@ def array_input(request):
28
27
return request .param
29
28
30
29
31
- def test_numpy_not_in_loaded_modules (self ):
30
+ def test_numpy_not_in_loaded_modules ():
32
31
"""Numpy should not be in the imported modules."""
33
32
assert "numpy" not in sys .modules
34
33
@@ -83,7 +82,7 @@ def test_slice(self):
83
82
array = Array1D (array_inp )
84
83
array_slice = array [1 :- 2 ]
85
84
assert isinstance (array_slice , Array1D )
86
- assert list (array_slice ) == array_inp [1 :- 2 ]
85
+ assert list (array_slice ) == list ( array_inp [1 :- 2 ])
87
86
88
87
89
88
class TestRepresentation :
@@ -113,7 +112,10 @@ def test_self_operations(self, array_input):
113
112
for op in self .operators :
114
113
result = op (array , array )
115
114
for el1 , el2 in zip (result , array ):
116
- assert el1 == op (el2 , el2 )
115
+ try :
116
+ assert el1 == op (el2 , el2 )
117
+ except (ZeroDivisionError , TypeError ):
118
+ assert el1 is None
117
119
118
120
def test_uneven_array_raises (self , array_input ):
119
121
"""Arrays of different lengths should not be compatible."""
@@ -133,6 +135,6 @@ def test_one_null_broadcast(self, array_input):
133
135
null_array = Array1D ([None ])
134
136
for op in self .operators :
135
137
result1 = op (array , null_array )
136
- assert all ([pd . isnull ( x ) for x in result1 ])
138
+ assert all ([x is None for x in result1 ])
137
139
result2 = op (null_array , array )
138
- assert all ([pd . isnull ( x ) for x in result2 ])
140
+ assert all ([x is None for x in result2 ])
0 commit comments