Whatevery you wrote, it's just Python code. It can be executed even if your code does contain shebang line #!python3, etc. Here's the list of potential issues you can have.

Module is missing - set to None

Pythonista modules are not available outside of Pythonista. Like console for example.

One way to handle modules that are not available is to wrap import with try/except and set the module to None if it's not avaiable. See log.py for example. Actually it should be except ImportError instead of bare except. And then just check if module was set or not.

Module is missing - Mock

Another way is to use unittest.mock. If you do not want to check it against None, you can do something like:

try: import console except ImportError: console = unittest.mock.MagicMock()

Now you can call whatever from console, MagicMock handles it and your code doesn't crash. mock is useful not just for mocking non existing modules, but you can use it for other things like patching existing functions. You can even check if mocked method was called, check what arguments were passed, etc.

Basically, if you have a module/function which handles communication with some server, you can patch this module / function to avoid real communication and to return whatever you need for tests.

You can learn more here.

Tests

Here's an example how to write tests. It's simple, I just started, but you can get a clue. Tests like these are runnable from within Pythonista (Cmd U in Black Mamba or via play button).

Travis CI

And here's an example how to run style check & tests on Travis CI.

You'll probably see more issue than these mentioned ones, but it's a good starting point and it should solve major issues for you.