jeudi 24 septembre 2020

Unable to run unit test from importing function - Python

I feel like I may be missing something very obvious here, but when I create a class for a unit test within my main Python file I am able to run the unit test successfully. However, when I try to import the class into a separate test.py file, there is absolutely no output. The two .py files are located in the same directory. Here is some of the code from the test file:

import sys
sys.path.append('/path/to/files')
import unittest
from mainfilename import Fraction

#Class for unit test
class TestOperatorEval(unittest.TestCase):

    #Create instances of Fractions
    def SetUp(self):
        self.Fraction = Fraction()

    #For successful test cases
    def test_OperatorEval_success(self) -> None:
        # Fractions to test
        f49: Fraction = Fraction(4, 9)
        f15: Fraction = Fraction(1, 5)
        f2945: Fraction = Fraction(29, 45)

        self.assertEqual(f49.__add__(f15), f2945)
    
if __name__ == '__main__':
    unittest.main()
    main()

This same block of code runs perfectly fine with a passed test when it's in the main file. What could I do next to troubleshoot?

Aucun commentaire:

Enregistrer un commentaire