Skip to content

Commit 350988b

Browse files
authored
Remove usage of py.std (#621)
1 parent f809b9a commit 350988b

File tree

6 files changed

+25
-24
lines changed

6 files changed

+25
-24
lines changed

tests/test_interpreters.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import sys
22
import os
3+
import subprocess
34

45
import py
56
import pytest
@@ -54,8 +55,7 @@ class envconfig:
5455
envconfig.basepython = name
5556
p = tox_get_python_executable(envconfig)
5657
assert p
57-
popen = py.std.subprocess.Popen([str(p), '-V'],
58-
stderr=py.std.subprocess.PIPE)
58+
popen = subprocess.Popen([str(p), '-V'], stderr=subprocess.PIPE)
5959
stdout, stderr = popen.communicate()
6060
assert ver in stderr.decode('ascii')
6161

tests/test_result.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import socket
12
import sys
23
import py
34
from tox.result import ResultLog
@@ -19,7 +20,7 @@ def test_pre_set_header(pkg):
1920
assert replog.dict["reportversion"] == "1"
2021
assert replog.dict["toxversion"] == tox.__version__
2122
assert replog.dict["platform"] == sys.platform
22-
assert replog.dict["host"] == py.std.socket.getfqdn()
23+
assert replog.dict["host"] == socket.getfqdn()
2324
data = replog.dumps_json()
2425
replog2 = ResultLog.loads_json(data)
2526
assert replog2.dict == replog.dict
@@ -33,7 +34,7 @@ def test_set_header(pkg):
3334
assert replog.dict["reportversion"] == "1"
3435
assert replog.dict["toxversion"] == tox.__version__
3536
assert replog.dict["platform"] == sys.platform
36-
assert replog.dict["host"] == py.std.socket.getfqdn()
37+
assert replog.dict["host"] == socket.getfqdn()
3738
assert replog.dict["installpkg"] == {
3839
"basename": "hello-1.0.tar.gz",
3940
"md5": pkg.computehash("md5"),

tox/_pytestplugin.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import sys
88
from fnmatch import fnmatch
99
import six
10+
import subprocess
11+
import textwrap
1012
import time
1113
from .config import parseconfig
1214
from .venv import VirtualEnv
@@ -37,7 +39,7 @@ def newconfig(args, source=None, plugins=()):
3739
if source is None:
3840
source = args
3941
args = []
40-
s = py.std.textwrap.dedent(source)
42+
s = textwrap.dedent(source)
4143
p = tmpdir.join("tox.ini")
4244
p.write(s)
4345
old = tmpdir.chdir()
@@ -190,14 +192,12 @@ def chdir(self, target):
190192
target.chdir()
191193

192194
def popen(self, argv, stdout, stderr, **kw):
193-
if not hasattr(py.std, 'subprocess'):
194-
pytest.skip("no subprocess module")
195195
env = os.environ.copy()
196196
env['PYTHONPATH'] = ":".join(filter(None, [
197197
str(os.getcwd()), env.get('PYTHONPATH', '')]))
198198
kw['env'] = env
199199
# print "env", env
200-
return py.std.subprocess.Popen(argv, stdout=stdout, stderr=stderr, **kw)
200+
return subprocess.Popen(argv, stdout=stdout, stderr=stderr, **kw)
201201

202202
def run(self, *argv):
203203
if argv[0] == "tox" and sys.version_info[:2] < (2, 7):
@@ -339,5 +339,5 @@ def create_files(base, filedefs):
339339
if isinstance(value, dict):
340340
create_files(base.ensure(key, dir=1), value)
341341
elif isinstance(value, str):
342-
s = py.std.textwrap.dedent(value)
342+
s = textwrap.dedent(value)
343343
base.join(key).write(s)

tox/result.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import socket
12
import sys
23
import py
34
from tox import __version__ as toxver
@@ -12,7 +13,7 @@ def __init__(self, dict=None):
1213
self.dict = dict
1314
self.dict.update({"reportversion": "1", "toxversion": toxver})
1415
self.dict["platform"] = sys.platform
15-
self.dict["host"] = py.std.socket.getfqdn()
16+
self.dict["host"] = socket.getfqdn()
1617

1718
def set_header(self, installpkg):
1819
"""

tox/session.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,18 @@
1010
import tox
1111
import py
1212
import os
13-
import sys
13+
import re
14+
import shutil
1415
import subprocess
16+
import sys
17+
import time
1518
from tox._verlib import NormalizedVersion, IrrationalVersionError
1619
from tox.venv import VirtualEnv
1720
from tox.config import parseconfig
1821
from tox.result import ResultLog
1922
from subprocess import STDOUT
2023

2124

22-
def now():
23-
return py.std.time.time()
24-
25-
2625
def prepare(args):
2726
config = parseconfig(args)
2827
if config.option.help:
@@ -154,26 +153,26 @@ def popen(self, args, cwd=None, env=None, redirect=True, returnout=False, ignore
154153
if resultjson and not redirect:
155154
assert popen.stderr is None # prevent deadlock
156155
out = None
157-
last_time = now()
156+
last_time = time.time()
158157
while 1:
159158
fin_pos = fin.tell()
160159
# we have to read one byte at a time, otherwise there
161160
# might be no output for a long time with slow tests
162161
data = fin.read(1)
163162
if data:
164163
sys.stdout.write(data)
165-
if '\n' in data or (now() - last_time) > 1:
164+
if '\n' in data or (time.time() - last_time) > 1:
166165
# we flush on newlines or after 1 second to
167166
# provide quick enough feedback to the user
168167
# when printing a dot per test
169168
sys.stdout.flush()
170-
last_time = now()
169+
last_time = time.time()
171170
elif popen.poll() is not None:
172171
if popen.stdout is not None:
173172
popen.stdout.close()
174173
break
175174
else:
176-
py.std.time.sleep(0.1)
175+
time.sleep(0.1)
177176
fin.seek(fin_pos)
178177
fin.close()
179178
else:
@@ -257,10 +256,10 @@ def logaction_start(self, action):
257256
msg = action.msg + " " + " ".join(map(str, action.args))
258257
self.verbosity2("%s start: %s" % (action.venvname, msg), bold=True)
259258
assert not hasattr(action, "_starttime")
260-
action._starttime = now()
259+
action._starttime = time.time()
261260

262261
def logaction_finish(self, action):
263-
duration = now() - action._starttime
262+
duration = time.time() - action._starttime
264263
# self.cumulated_time += duration
265264
self.verbosity2("%s finish: %s after %.2f seconds" % (
266265
action.venvname, action.msg, duration), bold=True)
@@ -437,7 +436,7 @@ def _makesdist(self):
437436
def make_emptydir(self, path):
438437
if path.check():
439438
self.report.info(" removing %s" % path)
440-
py.std.shutil.rmtree(str(path), ignore_errors=True)
439+
shutil.rmtree(str(path), ignore_errors=True)
441440
path.ensure(dir=1)
442441

443442
def setupenv(self, venv):
@@ -717,7 +716,7 @@ def _resolvepkg(self, pkgspec):
717716
return candidates[0]
718717

719718

720-
_rex_getversion = py.std.re.compile("[\w_\-\+\.]+-(.*)(\.zip|\.tar.gz)")
719+
_rex_getversion = re.compile("[\w_\-\+\.]+-(.*)(\.zip|\.tar.gz)")
721720

722721

723722
def getversion(basename):

tox/venv.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ def tox_testenv_create(venv, action):
433433
# default (virtualenv.ini)
434434
args.extend(['--python', str(config_interpreter)])
435435
# if sys.platform == "win32":
436-
# f, path, _ = py.std.imp.find_module("virtualenv")
436+
# f, path, _ = imp.find_module("virtualenv")
437437
# f.close()
438438
# args[:1] = [str(config_interpreter), str(path)]
439439
# else:

0 commit comments

Comments
 (0)