Skip to content

Commit

Permalink
Improve support for VSCode
Browse files Browse the repository at this point in the history
  • Loading branch information
amotl committed Jun 19, 2021
1 parent e37d076 commit cbcc18a
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 4 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ services/winscp.rnd
.vs/VSWorkspaceState.json
.vs/ProjectSettings.json
f.01
.vscode/settings.json
funcs.py
.pytest_cache
.pytest_results
Expand Down
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"python.pythonPath": "${workspaceFolder}/.venv/bin/python",
"python.testing.pytestEnabled": true,
"python.testing.pytestPath": "${workspaceFolder}/.venv/bin/pytest"
}
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ mqttwarn changelog
in progress
===========

- Improve support for VSCode


2021-06-19 0.26.1
=================
Expand Down
11 changes: 11 additions & 0 deletions doc/sandbox.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,17 @@ will be able to launch the ``mqttwarn`` entrypoint without further ado.

Otherwise, setup the virtualenv manually by invoking those commands::

# On Linux
python3 -m venv .venv
source .venv/bin/activate

# On Windows
python -m venv .venv
.venv/Scripts/activate

pip install --editable=.[test] --upgrade

For properly configuring a virtualenv, please also read those fine resources:

- https://code.visualstudio.com/docs/python/environments
- https://medium.com/@kylehayes/using-a-python-virtualenv-environment-with-vscode-b5f057f44c6a
11 changes: 8 additions & 3 deletions tests/test_commands.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import os
import sys
from pathlib import Path

import pytest


def get_mqttwarn_path():
return Path(sys.executable).parent / Path("mqttwarn")


def test_command_dump_config(capfd):

command = "mqttwarn make-config"
command = "{} make-config".format(get_mqttwarn_path())

os.system(command)
stdout = capfd.readouterr().out
Expand All @@ -16,7 +21,7 @@ def test_command_dump_config(capfd):

def test_command_dump_samplefuncs(capfd):

command = "mqttwarn make-samplefuncs"
command = "{} make-samplefuncs".format(get_mqttwarn_path())

os.system(command)
stdout = capfd.readouterr().out
Expand All @@ -30,7 +35,7 @@ def test_command_standalone_plugin(capfd):
if sys.platform.startswith("win"):
raise pytest.xfail("Skipping test, fails on Windows")

command = """mqttwarn --plugin=log --options='{"message": "Hello world", "addrs": ["crit"]}'"""
command = """{} --plugin=log --options='{}'""".format(get_mqttwarn_path(), '{"message": "Hello world", "addrs": ["crit"]}')

os.system(command)
stderr = capfd.readouterr().err
Expand Down

0 comments on commit cbcc18a

Please sign in to comment.