I'm trying to unittest my code however I always obtain the following error:
ERROR: test_FlipVertically1D_empty_array (main.TestMarginSampling)
Traceback (most recent call last): File "C:\Users\s\anaconda3\lib\unittest\mock.py", line 1337, in patched return func(*newargs, **newkeywargs) TypeError: test_FlipVertically1D_empty_array() takes 1 positional argument but 2 were given
Here is the code for my class:
class FlipVertically1D:
@staticmethod
def calc(data: np.ndarray) -> np.ndarray:
return - data
and here the code for my unittest:
import pandas as pd
import numpy as np
import unittest
from unittest.mock import patch, MagicMock
from ddt import ddt, data, file_data, idata, unpack
from augmentation.augment import FlipVertically1D as FlipV1D
from augmentation.augment import FlipHorizontally1D as FlipH1D
from augmentation.augment import RandomFlipping1D as RandF1D
@ddt
class TestMarginSampling1D(unittest.TestCase):
def set_up(self):
pass
def tear_down(self):
pass #del self.y_predict
def test_FlipVertically1D_empty_array(self):
empty = FlipV1D.calc(np.array([]))
self.assertTrue(len(empty))
#self.assertEqual(FlipV1D.calc(), 0)
I first assumed that somewhere I passed a self too much but this didnt solve my problem