Import code

141 views
Skip to first unread message

Andy Buckle

unread,
Oct 21, 2021, 8:03:12 AM10/21/21
to QATrack+
One of my snippets in a test is heading towards 1000 lines. I would like to keep it in a git repository of its own, split it into multiple files, run unit tests and so on. what are my options for importing it? Do I have to make it into a package and install it into the qatrack3 venv with pip? Is there a simpler way?

tbe...@gmail.com

unread,
Oct 21, 2021, 8:34:23 AM10/21/21
to QATrack+
Hi,
you can just place your python file(s) in a subfolder under venv/qatrack31/lib/python3.x/site-packages/. Pip is not needed.
Python documentation for modules: https://docs.python.org/3/tutorial/modules.html
If you have more then one file you should create a package (a bit further down): https://docs.python.org/3/tutorial/modules.html#packages

Thomas

Randle Taylor

unread,
Oct 21, 2021, 8:53:27 AM10/21/21
to tbe...@gmail.com, QATrack+
Another option is just to create a package within QATrack+ itself.  For example, you could create a directory "mycustomcode" in the qatrack directory (don't forget an __init__.py file), at the same level as the qa, service_log, accounts, etc directories, then in your composite calculation you could do "from qatrack.mycustomcode.some_module import my_function".

Randy

--
You received this message because you are subscribed to the Google Groups "QATrack+" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qatrack+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/qatrack/491588f9-55bf-4048-a75a-1cb87d679fb0n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages