Skip to content

Remove usage of py.std #621

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tests/test_interpreters.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import sys
import os
import subprocess

import py
import pytest
Expand Down Expand Up @@ -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')

Expand Down
5 changes: 3 additions & 2 deletions tests/test_result.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import socket
import sys
import py
from tox.result import ResultLog
Expand All @@ -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
Expand All @@ -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"),
Expand Down
10 changes: 5 additions & 5 deletions tox/_pytestplugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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)
3 changes: 2 additions & 1 deletion tox/result.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import socket
import sys
import py
from tox import __version__ as toxver
Expand All @@ -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):
"""
Expand Down
25 changes: 12 additions & 13 deletions tox/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,18 @@
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
from tox.result import ResultLog
from subprocess import STDOUT


def now():
return py.std.time.time()


def prepare(args):
config = parseconfig(args)
if config.option.help:
Expand Down Expand Up @@ -154,26 +153,26 @@ 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
# might be no output for a long time with slow tests
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:
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion tox/venv.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down