Skip to content

Commit b274dd8

Browse files
committed
Replace path/path.py with pathlib & os
1 parent f6a541b commit b274dd8

File tree

4 files changed

+11
-21
lines changed

4 files changed

+11
-21
lines changed

pytest-shutil/pytest_shutil/run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def run_in_subprocess(fn, python=sys.executable, cd=None, timeout=None):
190190
Raises execnet.RemoteError on exception.
191191
"""
192192
pkl_fn, preargs = (_evaluate_fn_source, (fn,)) if isinstance(fn, str) else _make_pickleable(fn)
193-
spec = '//'.join(filter(None, ['popen', 'python=' + python, 'chdir=' + cd if cd else None]))
193+
spec = '//'.join(filter(None, ['popen', 'python=' + python, 'chdir=' + str(cd) if cd else None]))
194194

195195
def inner(*args, **kwargs):
196196
# execnet sends stdout to /dev/null :(

pytest-shutil/pytest_shutil/workspace.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,8 @@
77
import logging
88
import subprocess
99

10-
try:
11-
from path import Path
12-
except ImportError:
13-
from path import path as Path
14-
10+
from pathlib import Path
1511
import pytest
16-
from six import string_types
1712

1813
from . import cmdline
1914

@@ -23,15 +18,15 @@
2318
@pytest.yield_fixture()
2419
def workspace():
2520
""" Function-scoped temporary workspace that cleans up on exit.
26-
21+
2722
Attributes
2823
----------
2924
workspace (`path.path`): Path to the workspace directory.
3025
debug (bool): If set to True, will log more debug when running commands.
31-
delete (bool): If True, will always delete the workspace on teardown;
32-
.. If None, delete the workspace unless teardown occurs via an exception;
26+
delete (bool): If True, will always delete the workspace on teardown;
27+
.. If None, delete the workspace unless teardown occurs via an exception;
3328
.. If False, never delete the workspace on teardown.
34-
29+
3530
"""
3631
ws = Workspace()
3732
yield ws
@@ -99,7 +94,7 @@ def run(self, cmd, capture=False, check_rc=True, cd=None, shell=False, **kwargs)
9994
cd : `str`
10095
Path to chdir to, defaults to workspace root
10196
"""
102-
if isinstance(cmd, string_types):
97+
if isinstance(cmd, str):
10398
shell = True
10499
else:
105100
# Some of the command components might be path objects or numbers
@@ -116,7 +111,7 @@ def run(self, cmd, capture=False, check_rc=True, cd=None, shell=False, **kwargs)
116111
p = subprocess.Popen(cmd, shell=shell, **kwargs)
117112
(out, _) = p.communicate()
118113

119-
if out is not None and not isinstance(out, string_types):
114+
if out is not None and not isinstance(out, str):
120115
out = out.decode('utf-8')
121116

122117
if self.debug and capture:

pytest-shutil/setup.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,7 @@
1919

2020
install_requires = ['six',
2121
'execnet',
22-
'contextlib2;python_version<"3"',
2322
'pytest',
24-
'path>=16.12.0; python_version >= "3.5"',
25-
'path.py; python_version < "3.5"',
26-
'mock; python_version<"3.3"',
2723
'termcolor'
2824
]
2925

pytest-shutil/tests/unit/test_cmdline.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import stat
21
import os
32

43
from pytest_shutil import cmdline
@@ -16,7 +15,7 @@ def test_pretty_formatter():
1615
f.hr()
1716
f.p('A Paragraph', 'red')
1817
assert f.buffer == [
19-
'\x1b[1m\x1b[34m A Title\x1b[0m',
18+
'\x1b[1m\x1b[34m A Title\x1b[0m',
2019
'\x1b[1m\x1b[34m--------------------------------------------------------------------------------\x1b[0m',
2120
'\x1b[31mA Paragraph\x1b[0m'
2221
]
@@ -32,8 +31,8 @@ def test_tempdir():
3231
def test_copy_files(workspace):
3332
d1 = workspace.workspace / 'd1'
3433
d2 = workspace.workspace / 'd2'
35-
d1.makedirs()
36-
d2.makedirs()
34+
os.makedirs(d1)
35+
os.makedirs(d2)
3736
(d1 / 'foo').touch()
3837
(d1 / 'bar').touch()
3938
cmdline.copy_files(d1, d2)

0 commit comments

Comments
 (0)