diff --git a/tests/test_interpreters.py b/tests/test_interpreters.py index 3d09eb90e..c57c9dca5 100644 --- a/tests/test_interpreters.py +++ b/tests/test_interpreters.py @@ -1,5 +1,6 @@ import sys import os +import subprocess import py import pytest @@ -54,8 +55,7 @@ class envconfig: envconfig.basepython = name p = tox_get_python_executable(envconfig) assert p - popen = py.std.subprocess.Popen([str(p), '-V'], - stderr=py.std.subprocess.PIPE) + popen = subprocess.Popen([str(p), '-V'], stderr=subprocess.PIPE) stdout, stderr = popen.communicate() assert ver in stderr.decode('ascii') diff --git a/tests/test_result.py b/tests/test_result.py index 48dd8318e..161f03c42 100644 --- a/tests/test_result.py +++ b/tests/test_result.py @@ -1,3 +1,4 @@ +import socket import sys import py from tox.result import ResultLog @@ -19,7 +20,7 @@ def test_pre_set_header(pkg): assert replog.dict["reportversion"] == "1" assert replog.dict["toxversion"] == tox.__version__ assert replog.dict["platform"] == sys.platform - assert replog.dict["host"] == py.std.socket.getfqdn() + assert replog.dict["host"] == socket.getfqdn() data = replog.dumps_json() replog2 = ResultLog.loads_json(data) assert replog2.dict == replog.dict @@ -33,7 +34,7 @@ def test_set_header(pkg): assert replog.dict["reportversion"] == "1" assert replog.dict["toxversion"] == tox.__version__ assert replog.dict["platform"] == sys.platform - assert replog.dict["host"] == py.std.socket.getfqdn() + assert replog.dict["host"] == socket.getfqdn() assert replog.dict["installpkg"] == { "basename": "hello-1.0.tar.gz", "md5": pkg.computehash("md5"), diff --git a/tox/_pytestplugin.py b/tox/_pytestplugin.py index 733e729d7..a55e12d5b 100644 --- a/tox/_pytestplugin.py +++ b/tox/_pytestplugin.py @@ -7,6 +7,8 @@ import sys from fnmatch import fnmatch import six +import subprocess +import textwrap import time from .config import parseconfig from .venv import VirtualEnv @@ -37,7 +39,7 @@ def newconfig(args, source=None, plugins=()): if source is None: source = args args = [] - s = py.std.textwrap.dedent(source) + s = textwrap.dedent(source) p = tmpdir.join("tox.ini") p.write(s) old = tmpdir.chdir() @@ -190,14 +192,12 @@ def chdir(self, target): target.chdir() def popen(self, argv, stdout, stderr, **kw): - if not hasattr(py.std, 'subprocess'): - pytest.skip("no subprocess module") env = os.environ.copy() env['PYTHONPATH'] = ":".join(filter(None, [ str(os.getcwd()), env.get('PYTHONPATH', '')])) kw['env'] = env # print "env", env - return py.std.subprocess.Popen(argv, stdout=stdout, stderr=stderr, **kw) + return subprocess.Popen(argv, stdout=stdout, stderr=stderr, **kw) def run(self, *argv): if argv[0] == "tox" and sys.version_info[:2] < (2, 7): @@ -339,5 +339,5 @@ def create_files(base, filedefs): if isinstance(value, dict): create_files(base.ensure(key, dir=1), value) elif isinstance(value, str): - s = py.std.textwrap.dedent(value) + s = textwrap.dedent(value) base.join(key).write(s) diff --git a/tox/result.py b/tox/result.py index bad8cc37c..55a658689 100644 --- a/tox/result.py +++ b/tox/result.py @@ -1,3 +1,4 @@ +import socket import sys import py from tox import __version__ as toxver @@ -12,7 +13,7 @@ def __init__(self, dict=None): self.dict = dict self.dict.update({"reportversion": "1", "toxversion": toxver}) self.dict["platform"] = sys.platform - self.dict["host"] = py.std.socket.getfqdn() + self.dict["host"] = socket.getfqdn() def set_header(self, installpkg): """ diff --git a/tox/session.py b/tox/session.py index 60f6b55f4..16b077691 100644 --- a/tox/session.py +++ b/tox/session.py @@ -10,8 +10,11 @@ import tox import py import os -import sys +import re +import shutil import subprocess +import sys +import time from tox._verlib import NormalizedVersion, IrrationalVersionError from tox.venv import VirtualEnv from tox.config import parseconfig @@ -19,10 +22,6 @@ from subprocess import STDOUT -def now(): - return py.std.time.time() - - def prepare(args): config = parseconfig(args) if config.option.help: @@ -154,7 +153,7 @@ def popen(self, args, cwd=None, env=None, redirect=True, returnout=False, ignore if resultjson and not redirect: assert popen.stderr is None # prevent deadlock out = None - last_time = now() + last_time = time.time() while 1: fin_pos = fin.tell() # we have to read one byte at a time, otherwise there @@ -162,18 +161,18 @@ def popen(self, args, cwd=None, env=None, redirect=True, returnout=False, ignore data = fin.read(1) if data: sys.stdout.write(data) - if '\n' in data or (now() - last_time) > 1: + if '\n' in data or (time.time() - last_time) > 1: # we flush on newlines or after 1 second to # provide quick enough feedback to the user # when printing a dot per test sys.stdout.flush() - last_time = now() + last_time = time.time() elif popen.poll() is not None: if popen.stdout is not None: popen.stdout.close() break else: - py.std.time.sleep(0.1) + time.sleep(0.1) fin.seek(fin_pos) fin.close() else: @@ -257,10 +256,10 @@ def logaction_start(self, action): msg = action.msg + " " + " ".join(map(str, action.args)) self.verbosity2("%s start: %s" % (action.venvname, msg), bold=True) assert not hasattr(action, "_starttime") - action._starttime = now() + action._starttime = time.time() def logaction_finish(self, action): - duration = now() - action._starttime + duration = time.time() - action._starttime # self.cumulated_time += duration self.verbosity2("%s finish: %s after %.2f seconds" % ( action.venvname, action.msg, duration), bold=True) @@ -437,7 +436,7 @@ def _makesdist(self): def make_emptydir(self, path): if path.check(): self.report.info(" removing %s" % path) - py.std.shutil.rmtree(str(path), ignore_errors=True) + shutil.rmtree(str(path), ignore_errors=True) path.ensure(dir=1) def setupenv(self, venv): @@ -717,7 +716,7 @@ def _resolvepkg(self, pkgspec): return candidates[0] -_rex_getversion = py.std.re.compile("[\w_\-\+\.]+-(.*)(\.zip|\.tar.gz)") +_rex_getversion = re.compile("[\w_\-\+\.]+-(.*)(\.zip|\.tar.gz)") def getversion(basename): diff --git a/tox/venv.py b/tox/venv.py index 8f985a028..2c66cb887 100755 --- a/tox/venv.py +++ b/tox/venv.py @@ -433,7 +433,7 @@ def tox_testenv_create(venv, action): # default (virtualenv.ini) args.extend(['--python', str(config_interpreter)]) # if sys.platform == "win32": - # f, path, _ = py.std.imp.find_module("virtualenv") + # f, path, _ = imp.find_module("virtualenv") # f.close() # args[:1] = [str(config_interpreter), str(path)] # else: