asfaltboy / SublimeTestPlier

run python tests quickly from within a project
https://packagecontrol.io/packages/Test%20Plier
MIT License
10 stars 4 forks source link

Can't run tests externally #15

Closed StabbarN closed 7 years ago

StabbarN commented 7 years ago

Cmd+shift+b and choosing "SublimeTestPlier" works perfectly but I also want to run tests externally for enabling pdb. Cmd+shift+b and choosing "SublimeTestPlier - python tests external" gives error:

/Users/magnus/projects/proj/venv-2.7/bin/python: can't find 'main' module in '/Users/magnus/Library/Application Support/Sublime Text 3/Installed Packages/Test Plier.sublime-package/utils/run_externally.py'

In my Sublime project file I've tried specifying python paths (and restarted sublime) to no avail:

"settings":
    {
     "python_interpreter": "/Users/magnus/projects/proj/venv-2.7/bin/python",
    },
    "build_systems": [
        {
            "name": "Test Plier",
            "target": "run_python_tests",
             "env":
            {
                "PYTHONPATH": "/Users/magnus/projects/proj/venv-2.7/lib/python2.7/site-packages",
            },
            "working_dir": "/Users/magnus/projects/proj/"
        }
    ]

Any idea what the problem might be? Virtual env? Python path problem in spawned child process? Thanks in advance!

asfaltboy commented 7 years ago

I just tested the default external command, and it seems the trouble is locating the helper scripts in the package when installed form package control, since they are archived inside the Test Plier.sublime-package file. I will work on this issue when I find the time (PRs are welcome!).

There are a few options for you to work around this:

  1. Download and place the utils folder from this repo into: /Users/magnus/Library/Application Support/Sublime Text 3/Packages/Test Plier this follows the packagecontrol's guide for overriding specific files.
  2. Specify your own launch script by writing something similar to run_externally.py that launches a terminal window and passes it the given test command (from the remaining arguments sys.argv[1:]).

    This script can be placed anywhere and then specified in your build settings updated like so:

    {
       "external": "~/bin/launch_external_test.py",
       "name": "Test Plier",
       "target": "run_python_tests",
        "env":
       {
           "PYTHONPATH": "/Users/magnus/projects/proj/venv-2.7/lib/python2.7/site-packages",
       },
       "working_dir": "/Users/magnus/projects/proj/"
    }