To load data from a file in a unittest, if the testdata is on the same dir as unittests, one solution :
TESTDATA_FILENAME = os.path.join(os.path.dirname(__file__), 'testdata.html')
class MyTest(unittest.TestCase)
def setUp(self):
self.testdata = open(TESTDATA_FILENAME).read()
def test_something(self):
....
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…