Skip to content

Remove usage of py.builtin #617

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 9, 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
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def main():
version = sys.version_info[:2]
virtualenv_open = ['virtualenv>=1.11.2']
virtualenv_capped = ['virtualenv>=1.11.2,<14']
install_requires = ['py>=1.4.17', 'pluggy>=0.3.0,<1.0']
install_requires = ['py>=1.4.17', 'pluggy>=0.3.0,<1.0', 'six']
extras_require = {}
if has_environment_marker_support():
extras_require[':python_version=="2.6"'] = ['argparse']
Expand Down
2 changes: 1 addition & 1 deletion tests/test_interpreters.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class envconfig:
popen = py.std.subprocess.Popen([str(p), '-V'],
stderr=py.std.subprocess.PIPE)
stdout, stderr = popen.communicate()
assert ver in py.builtin._totext(stderr, "ascii")
assert ver in stderr.decode('ascii')


def test_find_executable_extra(monkeypatch):
Expand Down
21 changes: 13 additions & 8 deletions tox/_pytestplugin.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from __future__ import print_function

import py
import pytest
import tox
import os
import sys
from py.builtin import _isbytes, _istext, print_
from fnmatch import fnmatch
import six
import time
from .config import parseconfig
from .venv import VirtualEnv
Expand Down Expand Up @@ -222,7 +224,7 @@ def run(self, *argv):
def dump_lines(lines, fp):
try:
for line in lines:
py.builtin.print_(line, file=fp)
print(line, file=fp)
except UnicodeEncodeError:
print("couldn't print to %s because of encoding" % (fp,))
dump_lines(out, sys.stdout)
Expand Down Expand Up @@ -271,17 +273,17 @@ def fnmatch_lines(self, lines2):
while lines1:
nextline = lines1.pop(0)
if line == nextline:
print_("exact match:", repr(line))
print("exact match:", repr(line))
break
elif fnmatch(nextline, line):
print_("fnmatch:", repr(line))
print_(" with:", repr(nextline))
print("fnmatch:", repr(line))
print(" with:", repr(nextline))
break
else:
if not nomatchprinted:
print_("nomatch:", repr(line))
print("nomatch:", repr(line))
nomatchprinted = True
print_(" and:", repr(nextline))
print(" and:", repr(nextline))
extralines.append(nextline)
else:
assert line == nextline
Expand All @@ -293,7 +295,10 @@ def initproj(request, tmpdir):
def initproj(nameversion, filedefs=None, src_root="."):
if filedefs is None:
filedefs = {}
if _istext(nameversion) or _isbytes(nameversion):
if (

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is string_types for matching both

isinstance(nameversion, six.text_type) or
isinstance(nameversion, bytes)
):
parts = nameversion.split("-")
if len(parts) == 1:
parts.append("0.1")
Expand Down
10 changes: 6 additions & 4 deletions tox/config.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import print_function

import argparse
import os
import random
Expand Down Expand Up @@ -243,7 +245,7 @@ def parseconfig(args=None, plugins=()):
except tox.exception.InterpreterNotFound:
exn = sys.exc_info()[1]
# Use stdout to match test expectations
py.builtin.print_("ERROR: " + str(exn))
print("ERROR: " + str(exn))

# post process config object
pm.hook.tox_configure(config=config)
Expand All @@ -252,15 +254,15 @@ def parseconfig(args=None, plugins=()):


def feedback(msg, sysexit=False):
py.builtin.print_("ERROR: " + msg, file=sys.stderr)
print("ERROR: " + msg, file=sys.stderr)
if sysexit:
raise SystemExit(1)


class VersionAction(argparse.Action):
def __call__(self, argparser, *args, **kwargs):
version = tox.__version__
py.builtin.print_("%s imported from %s" % (version, tox.__file__))
print("%s imported from %s" % (version, tox.__file__))
raise SystemExit(0)


Expand Down Expand Up @@ -1151,7 +1153,7 @@ def _replace_substitution(self, match):
val = self.reader._subs.get(sub_key, None)
if val is None:
val = self._substitute_from_other_section(sub_key)
if py.builtin.callable(val):
if callable(val):
val = val()
return str(val)

Expand Down
3 changes: 2 additions & 1 deletion tox/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
setup by using virtualenv. Configuration is generally done through an
INI-style "tox.ini" file.
"""
from __future__ import print_function
from __future__ import with_statement

import tox
Expand Down Expand Up @@ -325,7 +326,7 @@ def verbosity2(self, msg, **opts):
self.logline("%s" % msg, **opts)

# def log(self, msg):
# py.builtin.print_(msg, file=sys.stderr)
# print(msg, file=sys.stderr)


class Session:
Expand Down