I have to use python 2.2.6 for a project. I built it using PyCharm on Windows. In PyCharm, I can execute my test file, and it runs correctly. merge_sort_test
:
import unittest
from merge_sort.merge_sort import get_middle, merge, merge_sort
class MergeSortTest(unittest.TestCase):
def testGetMiddle_5_shouldBe2(self):
...
def main():
unittest.main()
if __name__ == '__main__':
main()
The folder structure is:
merge_sort
|__ __init__.py
|__ merge_sort.py
|__ test
|__ __init__.py
|__ merge_sort_test.py
I need to be able to run tests from a command line (in Windows and Unix), as well as within PyCharm.
However, I am not sure how to execute the test from the command line with correctly resolved dependencies.
If I execute the test file, I get the message No module named merge_sort.merge_sort
.
I have looked around StackOverflow for other ways to execute the test at the command line, without success. Some of them just don't work (at least with v2.2.6), but some of them I didn't understand. I am looking for an explanation of how to execute tests that can be understood by a Python novice.
Thanks in advance
Aucun commentaire:
Enregistrer un commentaire