Skip to content

Commit

Permalink
allow nosetests without env setup
Browse files Browse the repository at this point in the history
  • Loading branch information
bfredl committed Mar 29, 2016
1 parent cc24cd2 commit 69d6d0f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -34,7 +34,7 @@ install:
- pip install .
script:
- if [ $CI_TARGET = tests ]; then
NVIM_CHILD_ARGV='["nvim", "-u", "NONE", "--embed"]' nosetests;
nosetests;
else
flake8 neovim;
fi
Expand Down
10 changes: 8 additions & 2 deletions README.md
Expand Up @@ -118,10 +118,16 @@ to use it for the plugin host.
To run the tests execute

```sh
NVIM_CHILD_ARGV='["nvim", "-u", "NONE", "--embed"]' nosetests
nosetests
```

This will run the tests in an embedded instance of nvim.
If you want to test a different version than `nvim` in `$PATH` use
```sh
NVIM_CHILD_ARGV='["/path/to/nvim", "-u", "NONE", "--embed"]' nosetests
```

Alternatively, if you want to see the state of nvim, you could
Alternatively, if you want to see the state of nvim, you could use

```sh
export NVIM_LISTEN_ADDRESS=/tmp/nvimtest
Expand Down
11 changes: 8 additions & 3 deletions test/test_common.py
Expand Up @@ -8,10 +8,15 @@

neovim.setup_logging()

if 'NVIM_CHILD_ARGV' in os.environ:
vim = neovim.attach('child', argv=json.loads(os.environ['NVIM_CHILD_ARGV']))
child_argv = os.environ.get('NVIM_CHILD_ARGV')
listen_address = os.environ.get('NVIM_LISTEN_ADDRESS')
if child_argv is None and listen_address is None:
child_argv = '["nvim", "-u", "NONE", "--embed"]'

if child_argv is not None:
vim = neovim.attach('child', argv=json.loads(child_argv))
else:
vim = neovim.attach('socket', path=os.environ['NVIM_LISTEN_ADDRESS'])
vim = neovim.attach('socket', path=listen_address)

if sys.version_info >= (3, 0):
# For Python3 we decode binary strings as Unicode for compatibility
Expand Down

0 comments on commit 69d6d0f

Please sign in to comment.