Skip to content

Commit 9a5bd4a

Browse files
asottileobestwalter
authored andcommitted
Remove usage of py.builtin (#617)
1 parent 65cf618 commit 9a5bd4a

File tree

5 files changed

+23
-15
lines changed

5 files changed

+23
-15
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def main():
5050
version = sys.version_info[:2]
5151
virtualenv_open = ['virtualenv>=1.11.2']
5252
virtualenv_capped = ['virtualenv>=1.11.2,<14']
53-
install_requires = ['py>=1.4.17', 'pluggy>=0.3.0,<1.0']
53+
install_requires = ['py>=1.4.17', 'pluggy>=0.3.0,<1.0', 'six']
5454
extras_require = {}
5555
if has_environment_marker_support():
5656
extras_require[':python_version=="2.6"'] = ['argparse']

tests/test_interpreters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class envconfig:
5757
popen = py.std.subprocess.Popen([str(p), '-V'],
5858
stderr=py.std.subprocess.PIPE)
5959
stdout, stderr = popen.communicate()
60-
assert ver in py.builtin._totext(stderr, "ascii")
60+
assert ver in stderr.decode('ascii')
6161

6262

6363
def test_find_executable_extra(monkeypatch):

tox/_pytestplugin.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
from __future__ import print_function
2+
13
import py
24
import pytest
35
import tox
46
import os
57
import sys
6-
from py.builtin import _isbytes, _istext, print_
78
from fnmatch import fnmatch
9+
import six
810
import time
911
from .config import parseconfig
1012
from .venv import VirtualEnv
@@ -222,7 +224,7 @@ def run(self, *argv):
222224
def dump_lines(lines, fp):
223225
try:
224226
for line in lines:
225-
py.builtin.print_(line, file=fp)
227+
print(line, file=fp)
226228
except UnicodeEncodeError:
227229
print("couldn't print to %s because of encoding" % (fp,))
228230
dump_lines(out, sys.stdout)
@@ -271,17 +273,17 @@ def fnmatch_lines(self, lines2):
271273
while lines1:
272274
nextline = lines1.pop(0)
273275
if line == nextline:
274-
print_("exact match:", repr(line))
276+
print("exact match:", repr(line))
275277
break
276278
elif fnmatch(nextline, line):
277-
print_("fnmatch:", repr(line))
278-
print_(" with:", repr(nextline))
279+
print("fnmatch:", repr(line))
280+
print(" with:", repr(nextline))
279281
break
280282
else:
281283
if not nomatchprinted:
282-
print_("nomatch:", repr(line))
284+
print("nomatch:", repr(line))
283285
nomatchprinted = True
284-
print_(" and:", repr(nextline))
286+
print(" and:", repr(nextline))
285287
extralines.append(nextline)
286288
else:
287289
assert line == nextline
@@ -293,7 +295,10 @@ def initproj(request, tmpdir):
293295
def initproj(nameversion, filedefs=None, src_root="."):
294296
if filedefs is None:
295297
filedefs = {}
296-
if _istext(nameversion) or _isbytes(nameversion):
298+
if (
299+
isinstance(nameversion, six.text_type) or
300+
isinstance(nameversion, bytes)
301+
):
297302
parts = nameversion.split("-")
298303
if len(parts) == 1:
299304
parts.append("0.1")

tox/config.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import print_function
2+
13
import argparse
24
import os
35
import random
@@ -243,7 +245,7 @@ def parseconfig(args=None, plugins=()):
243245
except tox.exception.InterpreterNotFound:
244246
exn = sys.exc_info()[1]
245247
# Use stdout to match test expectations
246-
py.builtin.print_("ERROR: " + str(exn))
248+
print("ERROR: " + str(exn))
247249

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

253255

254256
def feedback(msg, sysexit=False):
255-
py.builtin.print_("ERROR: " + msg, file=sys.stderr)
257+
print("ERROR: " + msg, file=sys.stderr)
256258
if sysexit:
257259
raise SystemExit(1)
258260

259261

260262
class VersionAction(argparse.Action):
261263
def __call__(self, argparser, *args, **kwargs):
262264
version = tox.__version__
263-
py.builtin.print_("%s imported from %s" % (version, tox.__file__))
265+
print("%s imported from %s" % (version, tox.__file__))
264266
raise SystemExit(0)
265267

266268

@@ -1151,7 +1153,7 @@ def _replace_substitution(self, match):
11511153
val = self.reader._subs.get(sub_key, None)
11521154
if val is None:
11531155
val = self._substitute_from_other_section(sub_key)
1154-
if py.builtin.callable(val):
1156+
if callable(val):
11551157
val = val()
11561158
return str(val)
11571159

tox/session.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
setup by using virtualenv. Configuration is generally done through an
55
INI-style "tox.ini" file.
66
"""
7+
from __future__ import print_function
78
from __future__ import with_statement
89

910
import tox
@@ -325,7 +326,7 @@ def verbosity2(self, msg, **opts):
325326
self.logline("%s" % msg, **opts)
326327

327328
# def log(self, msg):
328-
# py.builtin.print_(msg, file=sys.stderr)
329+
# print(msg, file=sys.stderr)
329330

330331

331332
class Session:

0 commit comments

Comments
 (0)