aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/windows.yml (renamed from .github/workflows/windows_sanity.yml)13
-rw-r--r--poetry.lock34
-rw-r--r--pyproject.toml4
-rw-r--r--taskipy/task_runner.py14
-rw-r--r--tests/test_taskipy.py2
-rw-r--r--tests/test_windows.py26
-rw-r--r--tests/test_windows_sanity.py11
-rw-r--r--tests/utils/project.py2
8 files changed, 69 insertions, 37 deletions
diff --git a/.github/workflows/windows_sanity.yml b/.github/workflows/windows.yml
index a27afb3..980d0bd 100644
--- a/.github/workflows/windows_sanity.yml
+++ b/.github/workflows/windows.yml
@@ -1,6 +1,7 @@
-# This workflow checks that windows paths (a\b\c) work correctly when passed as args to taskipy
+# This workflow checks that windows paths (a\b\c) work correctly when
+# passed as args to taskipy and that mslex is installed.
-name: Taskipy Windows Sanity Test
+name: Taskipy Windows Tests
on:
push:
@@ -13,15 +14,15 @@ jobs:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- - name: Set up Python 3.8
+ - name: Set up Python 3.9
uses: actions/setup-python@v2
with:
- python-version: 3.8
+ python-version: 3.9
- name: Install Poetry
run: |
python -m pip install --upgrade pip
pip install poetry
- name: Install dependencies
run: poetry install
- - name: Test Windows-Style Paths
- run: poetry run task run_unittest_as_windows_sanity tests\test_windows_sanity.py
+ - name: Test Windows
+ run: poetry run task test_windows
diff --git a/poetry.lock b/poetry.lock
index 6f001da..35aa43c 100644
--- a/poetry.lock
+++ b/poetry.lock
@@ -1,6 +1,6 @@
[[package]]
name = "astroid"
-version = "2.5.6"
+version = "2.7.2"
description = "An abstract syntax tree for Python with inference support."
category = "dev"
optional = false
@@ -9,6 +9,7 @@ python-versions = "~=3.6"
[package.dependencies]
lazy-object-proxy = ">=1.4.0"
typed-ast = {version = ">=1.4.0,<1.5", markers = "implementation_name == \"cpython\" and python_version < \"3.8\""}
+typing-extensions = {version = ">=3.7.4", markers = "python_version < \"3.8\""}
wrapt = ">=1.11,<1.13"
[[package]]
@@ -81,6 +82,18 @@ optional = false
python-versions = "*"
[[package]]
+name = "platformdirs"
+version = "2.2.0"
+description = "A small Python module for determining appropriate platform-specific dirs, e.g. a \"user data dir\"."
+category = "dev"
+optional = false
+python-versions = ">=3.6"
+
+[package.extras]
+docs = ["Sphinx (>=4)", "furo (>=2021.7.5b38)", "proselint (>=0.10.2)", "sphinx-autodoc-typehints (>=1.12)"]
+test = ["appdirs (==1.4.4)", "pytest (>=6)", "pytest-cov (>=2.7)", "pytest-mock (>=3.6)"]
+
+[[package]]
name = "psutil"
version = "5.8.0"
description = "Cross-platform lib for process and system monitoring in Python."
@@ -93,17 +106,18 @@ test = ["ipaddress", "mock", "unittest2", "enum34", "pywin32", "wmi"]
[[package]]
name = "pylint"
-version = "2.8.2"
+version = "2.10.2"
description = "python code static checker"
category = "dev"
optional = false
python-versions = "~=3.6"
[package.dependencies]
-astroid = ">=2.5.6,<2.7"
+astroid = ">=2.7.2,<2.8"
colorama = {version = "*", markers = "sys_platform == \"win32\""}
isort = ">=4.2.5,<6"
mccabe = ">=0.6,<0.7"
+platformdirs = ">=2.2.0"
toml = ">=0.7.1"
[[package]]
@@ -149,12 +163,12 @@ python-versions = "*"
[metadata]
lock-version = "1.1"
python-versions = "^3.6"
-content-hash = "788a82707e70e2638ef6e96717e0c3159de334d4f1c2ae9262138e404fafe8c4"
+content-hash = "c9a3d6446ca128dfc7e9a80a6776ed4d646dc0b125bae9e5e6c84d609564918c"
[metadata.files]
astroid = [
- {file = "astroid-2.5.6-py3-none-any.whl", hash = "sha256:4db03ab5fc3340cf619dbc25e42c2cc3755154ce6009469766d7143d1fc2ee4e"},
- {file = "astroid-2.5.6.tar.gz", hash = "sha256:8a398dfce302c13f14bab13e2b14fe385d32b73f4e4853b9bdfb64598baa1975"},
+ {file = "astroid-2.7.2-py3-none-any.whl", hash = "sha256:ecc50f9b3803ebf8ea19aa2c6df5622d8a5c31456a53c741d3be044d96ff0948"},
+ {file = "astroid-2.7.2.tar.gz", hash = "sha256:b6c2d75cd7c2982d09e7d41d70213e863b3ba34d3bd4014e08f167cee966e99e"},
]
colorama = [
{file = "colorama-0.4.4-py2.py3-none-any.whl", hash = "sha256:9f47eda37229f68eee03b24b9748937c7dc3868f906e8ba69fbcbdd3bc5dc3e2"},
@@ -224,6 +238,10 @@ mypy-extensions = [
{file = "mypy_extensions-0.4.3-py2.py3-none-any.whl", hash = "sha256:090fedd75945a69ae91ce1303b5824f428daf5a028d2f6ab8a299250a846f15d"},
{file = "mypy_extensions-0.4.3.tar.gz", hash = "sha256:2d82818f5bb3e369420cb3c4060a7970edba416647068eb4c5343488a6c604a8"},
]
+platformdirs = [
+ {file = "platformdirs-2.2.0-py3-none-any.whl", hash = "sha256:4666d822218db6a262bdfdc9c39d21f23b4cfdb08af331a81e92751daf6c866c"},
+ {file = "platformdirs-2.2.0.tar.gz", hash = "sha256:632daad3ab546bd8e6af0537d09805cec458dce201bccfe23012df73332e181e"},
+]
psutil = [
{file = "psutil-5.8.0-cp27-cp27m-macosx_10_9_x86_64.whl", hash = "sha256:0066a82f7b1b37d334e68697faba68e5ad5e858279fd6351c8ca6024e8d6ba64"},
{file = "psutil-5.8.0-cp27-cp27m-manylinux2010_i686.whl", hash = "sha256:0ae6f386d8d297177fd288be6e8d1afc05966878704dad9847719650e44fc49c"},
@@ -255,8 +273,8 @@ psutil = [
{file = "psutil-5.8.0.tar.gz", hash = "sha256:0c9ccb99ab76025f2f0bbecf341d4656e9c1351db8cc8a03ccd62e318ab4b5c6"},
]
pylint = [
- {file = "pylint-2.8.2-py3-none-any.whl", hash = "sha256:f7e2072654a6b6afdf5e2fb38147d3e2d2d43c89f648637baab63e026481279b"},
- {file = "pylint-2.8.2.tar.gz", hash = "sha256:586d8fa9b1891f4b725f587ef267abe2a1bad89d6b184520c7f07a253dd6e217"},
+ {file = "pylint-2.10.2-py3-none-any.whl", hash = "sha256:e178e96b6ba171f8ef51fbce9ca30931e6acbea4a155074d80cc081596c9e852"},
+ {file = "pylint-2.10.2.tar.gz", hash = "sha256:6758cce3ddbab60c52b57dcc07f0c5d779e5daf0cf50f6faacbef1d3ea62d2a1"},
]
rope = [
{file = "rope-0.14.0-py2-none-any.whl", hash = "sha256:6b728fdc3e98a83446c27a91fc5d56808a004f8beab7a31ab1d7224cecc7d969"},
diff --git a/pyproject.toml b/pyproject.toml
index ac87bb8..9b6e52e 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -23,7 +23,7 @@ task = 'taskipy.cli:main'
python = "^3.6"
toml = "^0.10.0"
psutil = "^5.7.2"
-mslex = "^0.3.0"
+mslex = { version = "^0.3.0", markers = "sys_platform == 'win32'" }
colorama = "^0.4.4"
[tool.poetry.dev-dependencies]
@@ -36,7 +36,7 @@ psutil = "^5.6.7"
test = { cmd = "python -m unittest -v tests/test_*.py", help = "runs all tests" }
post_test = "./task lint"
-run_unittest_as_windows_sanity = { cmd = "python -m unittest -v", help = "this is a command that is run by our Windows CI on Github" }
+test_windows = { cmd = "python -m unittest -v tests\\test_windows.py", help = "this is a command that is run by our Windows CI on Github" }
lint = { cmd = "./task lint_pylint && ./task lint_mypy", help = "lint project with pylint for style and mypy for typings" }
lint_pylint = "pylint tests taskipy"
diff --git a/taskipy/task_runner.py b/taskipy/task_runner.py
index 0aa3aa1..fb3f806 100644
--- a/taskipy/task_runner.py
+++ b/taskipy/task_runner.py
@@ -3,8 +3,6 @@ import platform
import psutil # type: ignore
import signal
import subprocess
-import shlex
-import mslex # type: ignore
from pathlib import Path
from typing import List, Union, Optional
@@ -13,6 +11,11 @@ from taskipy.exceptions import TaskNotFoundError
from taskipy.task import Task
from taskipy.help import HelpFormatter
+if platform.system() == 'Windows':
+ import mslex as shlex # type: ignore # pylint: disable=E0401
+else:
+ import shlex # type: ignore[no-redef]
+
class TaskRunner:
def __init__(self, cwd: Union[str, Path]):
@@ -56,11 +59,6 @@ class TaskRunner:
if self.__project.runner is not None:
command = f'{self.__project.runner} {command}'
- def quote_arg(arg: str) -> str:
- if platform.system() == 'Windows':
- return mslex.quote(arg)
- return shlex.quote(arg)
-
def send_signal_to_task_process(signum: int, _frame) -> None:
# pylint: disable=W0640
psutil_process_wrapper = psutil.Process(process.pid)
@@ -75,7 +73,7 @@ class TaskRunner:
else:
process.send_signal(signum)
- command_with_args = ' '.join([command] + [quote_arg(arg) for arg in args])
+ command_with_args = ' '.join([command] + [shlex.quote(arg) for arg in args])
process = subprocess.Popen(command_with_args,
shell=True,
cwd=self.__working_dir)
diff --git a/tests/test_taskipy.py b/tests/test_taskipy.py
index 84b767a..1598f0f 100644
--- a/tests/test_taskipy.py
+++ b/tests/test_taskipy.py
@@ -76,7 +76,7 @@ class RunTaskTestCase(TaskipyTestCase):
cwd = self.create_test_dir_from_fixture('project_with_pyproject_and_tasks')
self.run_task('create_hello_txt', cwd=cwd)
- with open(path.join(cwd, 'hello.txt'), 'r') as f:
+ with open(path.join(cwd, 'hello.txt'), 'r', encoding='utf-8') as f:
hello_file_contents = f.readline().strip()
self.assertEqual(hello_file_contents, 'hello, world')
diff --git a/tests/test_windows.py b/tests/test_windows.py
new file mode 100644
index 0000000..78ba69f
--- /dev/null
+++ b/tests/test_windows.py
@@ -0,0 +1,26 @@
+import platform
+
+import unittest
+
+
+@unittest.skipIf(platform.system() != 'Windows', 'Windows only tests')
+class WindowsTestCase(unittest.TestCase):
+ def test_windows_path_sanity(self):
+ '''
+ This test case is a no-op, and exists only to ensure that windows paths work
+ as part of the windows sanity ci test.
+ '''
+ print('sanity passed - test was run')
+
+ def test_mslex_install(self):
+ '''Ensure that mslex is installed on Windows'''
+ try:
+ import mslex # type: ignore # pylint: disable=W0611,C0415
+ except ImportError:
+ self.fail('Unable to import mslex')
+
+ def test_mslex_import(self):
+ '''Ensure that mslex is used as shlex'''
+ from taskipy.task_runner import shlex # pylint: disable=C0415
+
+ self.assertEqual(shlex.__name__, 'mslex')
diff --git a/tests/test_windows_sanity.py b/tests/test_windows_sanity.py
deleted file mode 100644
index 0b7dc55..0000000
--- a/tests/test_windows_sanity.py
+++ /dev/null
@@ -1,11 +0,0 @@
-import unittest
-
-
-class WindowsSanityTestCase(unittest.TestCase):
- '''
- This test case is a no-op, and exists only to ensure that windows paths work
- as part of the windows sanity ci test.
- '''
-
- def test_windows_sanity(self):
- print('sanity passed - test was run')
diff --git a/tests/utils/project.py b/tests/utils/project.py
index d6c151b..8df135a 100644
--- a/tests/utils/project.py
+++ b/tests/utils/project.py
@@ -24,7 +24,7 @@ class GenerateProjectWithPyProjectToml(ProjectDirGenerator):
def generate_project(self, temp_dir: str):
os.makedirs(temp_dir)
- with open(path.join(temp_dir, 'pyproject.toml'), 'w') as f:
+ with open(path.join(temp_dir, 'pyproject.toml'), 'w', encoding='utf-8') as f:
f.write(self._py_project_toml)