I created a DocTest file for the actual module I want to test and weirdly I don't get the import issue... I don't see any difference except the module I'm testing is two folder layers deep (.../Apps/AppName/appname.py
rather than .../HelloWorld/helloworld.py
). But as it's fully working with the module I actually want to test, that's fine for me for now.
Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.

Latest posts made by shfonic
-
RE: DocTests in seperate file not working
-
RE: DocTests in seperate file not working
Thanks JonB. The testing of the get_hello function works. However the test fails on the line of the
import helloworld
. It saysGot: (the info of sys.path)
. This does not stop me testing my code now, however it just has one failure due to this. Any thoughts? Thanks again.>>> import sys; _path = '/private/var/mobile/Containers/Shared/AppGroup/.../Pythonista3/Documents/HelloWorld'; sys.path.append(_path) >>> import helloworld >>> helloworld.get_hello("Richard") 'Hello Richard'
-
DocTests in seperate file not working
Hi, I'm having issues getting the DocTests to run as a seperate file using the built in DocTests feature (creating a file name.doctest file and pressing play). The DocTest file works when calling existing packages, but if I do the following:
New top-level folder called "HelloWorld"
New script called "helloworld.py" with the following code:def get_hello(name): return "Hello " + name
Then create a "helloworld.doctest" with the following:
>>> import helloworld >>> helloworld.get_hello("Richard") 'Hello Richard'
Then run the DocTest by pressing play (pressing play using the default template passes), I get the following error:
ImportError: No module named 'helloworld' NameError: name 'helloworld' is not defined
If I add the DocTest into the comment of the method, running DocTest works on that script. But I want to remove clutter and have the tests in a seperate file and use this feature.
def get_hello(name): """ >>> get_hello("Richard") 'Hello Richard' """ return "Hello " + name
Is there something I'm missing? Any help will be most appreciated