skolukmar
skolukmar

Reputation: 331

Python Pandas Unit Test is not recognized

I have an issue with unit test definition. I am going to test data frames and I do not understand why the following result is returned.

Result:

Ran 0 tests in 0.000s
OK

Script:

import unittest
import pandas as pd

from pandas._testing import assert_frame_equal

def df_minus(df_main:pd.DataFrame, df_subset:pd.DataFrame) -> pd.DataFrame :
    return df_main

class TestDataFrameMinus(unittest.TestCase):
    
    def df_minus_equal(self):
        df_A = pd.DataFrame(data={
            'col1': [1, 2, 3, 4]         
            }
        )        
        df_B = pd.DataFrame(data={
            'col1': [1, 2, 3]
            }
        )
        df_result = pd.DataFrame(data={
            'col1': [1, 2, 3]
            }
        )
        assert_frame_equal(df_minus(df_A, df_B), df_result)

if __name__ == '__main__':
    unittest.main()

Do you have any idea why the test is not visible?

Upvotes: 0

Views: 93

Answers (1)

Sina
Sina

Reputation: 1135

You should name your methods with test_ prefix

def test_df_minus_equal(self):
    pass

Upvotes: 1

Related Questions