I think that using file to figure out where the test is located and storing data alongside the it is a good idea. I'm doing the same for some tests that I write This: os.path. Dirname(os.path.
Abspath(__file__)) is probably the best you are going to get, and that's not bad. :-).
I think that using __file__ to figure out where the test is located and storing data alongside the it is a good idea. I'm doing the same for some tests that I write. This: os.path.
Dirname(os.path. Abspath(__file__)) is probably the best you are going to get, and that's not bad. :-).
Based on the idea of using __file__, maybe you could use a module to help with the path construction. You could find all the files contained in the module directory, gather their name and path in a dictionnary for later use. Create a module accessible to your tests, i.e.
A directory besides your test such as testData, where you can put your data files. In the __init__. Py of this module, insert the following code.
Import os from os. Path import join,dirname,abspath testDataFiles = dict() baseDir = dirname(abspath(__file__)) + os.path. Sep for root, dirs, files in os.
Walk(baseDir): localDataFiles = (join(root. Replace(baseDir,""),name), join(root,name)) for name in files testDataFiles. Update( dict(localDataFiles)) Assuming you called your module testData and it contains a file called data.
Txt you can then use the following construct in your test to obtain the path to the file. AFileOperation is assumed to be a function that take a parameter path import unittest from testData import testDataFiles class ATestCase(unittest. TestCase): def test_Something(self): self.
AssertEqual( 0, aFileOperation(testDataFiles'data. Txt' ) It will also allow you to use subdirectories such as def test_SomethingInASubDir(self): self. AssertEqual( 0, aFileOperation(testDataFiles'subdir\\data.
Txt' ).
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.