From 8f5382704be658d7ccae774b18e214a2187454c9 Mon Sep 17 00:00:00 2001 From: Kenny Do Date: Wed, 15 Feb 2023 22:00:36 -0800 Subject: [PATCH 1/2] Use quote from shlex --- .pre-commit-config.yaml | 2 +- aactivator.py | 2 +- setup.py | 4 ++-- tests/conftest.py | 7 ------- tests/integration_test.py | 4 +--- tox.ini | 2 +- 6 files changed, 6 insertions(+), 15 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5e73184..f6f0f23 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,7 +8,7 @@ repos: - id: debug-statements - id: end-of-file-fixer - id: trailing-whitespace -- repo: https://gitlab.com/pycqa/flake8 +- repo: https://github.com/pycqa/flake8 rev: 3.7.1 hooks: - id: flake8 diff --git a/aactivator.py b/aactivator.py index 121264c..2eef5a6 100755 --- a/aactivator.py +++ b/aactivator.py @@ -32,7 +32,7 @@ import stat import sys from os.path import relpath -from pipes import quote +from shlex import quote ENVIRONMENT_VARIABLE = 'AACTIVATOR_ACTIVE' diff --git a/setup.py b/setup.py index cf14834..afa6590 100644 --- a/setup.py +++ b/setup.py @@ -14,12 +14,12 @@ platforms='linux', classifiers=[ 'License :: OSI Approved :: MIT License', - 'Programming Language :: Python :: 2', - 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', ], + python_requires='>=3.3', py_modules=['aactivator'], entry_points={ 'console_scripts': [ diff --git a/tests/conftest.py b/tests/conftest.py index 93af4ab..96d1a18 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -4,13 +4,6 @@ from __future__ import unicode_literals import pytest -from py._path.local import LocalPath - - -@pytest.fixture(autouse=True) -def cwd(): - with LocalPath('/').as_cwd(): - yield @pytest.fixture diff --git a/tests/integration_test.py b/tests/integration_test.py index b4bb63c..6375856 100644 --- a/tests/integration_test.py +++ b/tests/integration_test.py @@ -8,6 +8,7 @@ import re import shutil import sys +from shlex import quote import pexpect import pytest @@ -60,8 +61,6 @@ def expect_exact_better(proc, expected): proc.buffer.replace(b'\r', b'').replace(b'\n', b'\n ').decode('utf8'), ) message = '\n'.join(message) - if sys.version_info < (3, 0): - message = message.encode('utf8') raise AssertionError(message) @@ -114,7 +113,6 @@ def parse_tests(tests): def shellquote(cmd): """transform a python command-list to a shell command-string""" - from pipes import quote return ' '.join(quote(arg) for arg in cmd) diff --git a/tox.ini b/tox.ini index 02b298b..473f31b 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py27,py36 +envlist = py36 [testenv] deps = -rrequirements-dev.txt From 3fb8480f9856c02259dcd524cc9e7b93f549ed02 Mon Sep 17 00:00:00 2001 From: Kenny Do Date: Thu, 16 Feb 2023 22:23:09 -0800 Subject: [PATCH 2/2] add back cwd fixture using os.chdir instead --- tests/conftest.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/conftest.py b/tests/conftest.py index 96d1a18..3389895 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -3,9 +3,22 @@ from __future__ import print_function from __future__ import unicode_literals +import os + import pytest +@pytest.fixture(autouse=True) +def cwd(): + old_dir = os.getcwd() + os.chdir('/') + + try: + yield + finally: + os.chdir(old_dir) + + @pytest.fixture def venv_path(tmpdir): return tmpdir.join('venv')