KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have just finished writing the core section of a project I am working on and I want to write test for it using unittest before I continue. I am aware that I should have done this before, but when I started I didn't know Python, so.. whatever.. What I would like to achieve: I have a sub-package of the main package which contains all the modules I want to test inside it. I want to put a subsubpackage inside that called 'tests' or something which then contains all of my test cases, which I'd like to be able to aggregate into a test suite from outside the package so eventually I can run all the test for the entire project in one go. The structure is something like this: /projectPackage /projectPackage/package /projectPackage/package/\__init__.py (empty) /projectPackage/package/someModule.py /projectPackage/package/... (more modules) /projectPackage/package/testing.py (runs all the tests in /tests/) /projectPackage/package/tests /projectPackage/package/tests/\__init__.py (empty) /projectPackage/package/tests/someModuleTests.py Problem I am having: someModuleTests has to import someModule from the parent package so it can test its methods. This doesn't seem to work. I get various errors like: Attempted relative import beyond toplevel package Anyway, I expect it's just because I am a Python noob! I have my own ideas on how I am going to do it for this project, because of course each is different, but any general advice on the structuring of medium-large python projects is also appreciated.
Tags (comma-separated)
Save Edits
Cancel