commit
f16d54f9a8
|
@ -6,6 +6,7 @@ Changes between 1.2.1 and 1.2.2 (release pending)
|
||||||
- (issue87) fix unboundlocal error in assertionold code
|
- (issue87) fix unboundlocal error in assertionold code
|
||||||
- (issue86) improve documentation for looponfailing
|
- (issue86) improve documentation for looponfailing
|
||||||
- fix jython/win32 issues
|
- fix jython/win32 issues
|
||||||
|
- ship distribute_setup.py version 0.6.10
|
||||||
|
|
||||||
|
|
||||||
Changes between 1.2.1 and 1.2.0
|
Changes between 1.2.1 and 1.2.0
|
||||||
|
|
|
@ -46,19 +46,21 @@ except ImportError:
|
||||||
args = [quote(arg) for arg in args]
|
args = [quote(arg) for arg in args]
|
||||||
return os.spawnl(os.P_WAIT, sys.executable, *args) == 0
|
return os.spawnl(os.P_WAIT, sys.executable, *args) == 0
|
||||||
|
|
||||||
DEFAULT_VERSION = "0.6.6"
|
DEFAULT_VERSION = "0.6.10"
|
||||||
DEFAULT_URL = "http://pypi.python.org/packages/source/d/distribute/"
|
DEFAULT_URL = "http://pypi.python.org/packages/source/d/distribute/"
|
||||||
|
SETUPTOOLS_FAKED_VERSION = "0.6c11"
|
||||||
|
|
||||||
SETUPTOOLS_PKG_INFO = """\
|
SETUPTOOLS_PKG_INFO = """\
|
||||||
Metadata-Version: 1.0
|
Metadata-Version: 1.0
|
||||||
Name: setuptools
|
Name: setuptools
|
||||||
Version: 0.6c9
|
Version: %s
|
||||||
Summary: xxxx
|
Summary: xxxx
|
||||||
Home-page: xxx
|
Home-page: xxx
|
||||||
Author: xxx
|
Author: xxx
|
||||||
Author-email: xxx
|
Author-email: xxx
|
||||||
License: xxx
|
License: xxx
|
||||||
Description: xxx
|
Description: xxx
|
||||||
"""
|
""" % SETUPTOOLS_FAKED_VERSION
|
||||||
|
|
||||||
|
|
||||||
def _install(tarball):
|
def _install(tarball):
|
||||||
|
@ -79,12 +81,14 @@ def _install(tarball):
|
||||||
|
|
||||||
# installing
|
# installing
|
||||||
log.warn('Installing Distribute')
|
log.warn('Installing Distribute')
|
||||||
assert _python_cmd('setup.py', 'install')
|
if not _python_cmd('setup.py', 'install'):
|
||||||
|
log.warn('Something went wrong during the installation.')
|
||||||
|
log.warn('See the error message above.')
|
||||||
finally:
|
finally:
|
||||||
os.chdir(old_wd)
|
os.chdir(old_wd)
|
||||||
|
|
||||||
|
|
||||||
def _build_egg(tarball, to_dir):
|
def _build_egg(egg, tarball, to_dir):
|
||||||
# extracting the tarball
|
# extracting the tarball
|
||||||
tmpdir = tempfile.mkdtemp()
|
tmpdir = tempfile.mkdtemp()
|
||||||
log.warn('Extracting in %s', tmpdir)
|
log.warn('Extracting in %s', tmpdir)
|
||||||
|
@ -104,27 +108,28 @@ def _build_egg(tarball, to_dir):
|
||||||
log.warn('Building a Distribute egg in %s', to_dir)
|
log.warn('Building a Distribute egg in %s', to_dir)
|
||||||
_python_cmd('setup.py', '-q', 'bdist_egg', '--dist-dir', to_dir)
|
_python_cmd('setup.py', '-q', 'bdist_egg', '--dist-dir', to_dir)
|
||||||
|
|
||||||
# returning the result
|
|
||||||
for file in os.listdir(to_dir):
|
|
||||||
if fnmatch.fnmatch(file, 'distribute-%s*.egg' % DEFAULT_VERSION):
|
|
||||||
return os.path.join(to_dir, file)
|
|
||||||
|
|
||||||
raise IOError('Could not build the egg.')
|
|
||||||
finally:
|
finally:
|
||||||
os.chdir(old_wd)
|
os.chdir(old_wd)
|
||||||
|
# returning the result
|
||||||
|
log.warn(egg)
|
||||||
|
if not os.path.exists(egg):
|
||||||
|
raise IOError('Could not build the egg.')
|
||||||
|
|
||||||
|
|
||||||
def _do_download(version, download_base, to_dir, download_delay):
|
def _do_download(version, download_base, to_dir, download_delay):
|
||||||
tarball = download_setuptools(version, download_base,
|
egg = os.path.join(to_dir, 'distribute-%s-py%d.%d.egg'
|
||||||
to_dir, download_delay)
|
% (version, sys.version_info[0], sys.version_info[1]))
|
||||||
egg = _build_egg(tarball, to_dir)
|
if not os.path.exists(egg):
|
||||||
|
tarball = download_setuptools(version, download_base,
|
||||||
|
to_dir, download_delay)
|
||||||
|
_build_egg(egg, tarball, to_dir)
|
||||||
sys.path.insert(0, egg)
|
sys.path.insert(0, egg)
|
||||||
import setuptools
|
import setuptools
|
||||||
setuptools.bootstrap_install_from = egg
|
setuptools.bootstrap_install_from = egg
|
||||||
|
|
||||||
|
|
||||||
def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,
|
def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,
|
||||||
to_dir=os.curdir, download_delay=15, no_fake=False):
|
to_dir=os.curdir, download_delay=15, no_fake=True):
|
||||||
# making sure we use the absolute path
|
# making sure we use the absolute path
|
||||||
to_dir = os.path.abspath(to_dir)
|
to_dir = os.path.abspath(to_dir)
|
||||||
was_imported = 'pkg_resources' in sys.modules or \
|
was_imported = 'pkg_resources' in sys.modules or \
|
||||||
|
@ -134,7 +139,7 @@ def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
if not hasattr(pkg_resources, '_distribute'):
|
if not hasattr(pkg_resources, '_distribute'):
|
||||||
if not no_fake:
|
if not no_fake:
|
||||||
fake_setuptools()
|
_fake_setuptools()
|
||||||
raise ImportError
|
raise ImportError
|
||||||
except ImportError:
|
except ImportError:
|
||||||
return _do_download(version, download_base, to_dir, download_delay)
|
return _do_download(version, download_base, to_dir, download_delay)
|
||||||
|
@ -159,7 +164,8 @@ def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,
|
||||||
return _do_download(version, download_base, to_dir,
|
return _do_download(version, download_base, to_dir,
|
||||||
download_delay)
|
download_delay)
|
||||||
finally:
|
finally:
|
||||||
_create_fake_setuptools_pkg_info(to_dir)
|
if not no_fake:
|
||||||
|
_create_fake_setuptools_pkg_info(to_dir)
|
||||||
|
|
||||||
def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,
|
def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,
|
||||||
to_dir=os.curdir, delay=15):
|
to_dir=os.curdir, delay=15):
|
||||||
|
@ -218,22 +224,34 @@ def _patch_file(path, content):
|
||||||
def _same_content(path, content):
|
def _same_content(path, content):
|
||||||
return open(path).read() == content
|
return open(path).read() == content
|
||||||
|
|
||||||
|
def _no_sandbox(function):
|
||||||
|
def __no_sandbox(*args, **kw):
|
||||||
|
try:
|
||||||
|
from setuptools.sandbox import DirectorySandbox
|
||||||
|
def violation(*args):
|
||||||
|
pass
|
||||||
|
DirectorySandbox._old = DirectorySandbox._violation
|
||||||
|
DirectorySandbox._violation = violation
|
||||||
|
patched = True
|
||||||
|
except ImportError:
|
||||||
|
patched = False
|
||||||
|
|
||||||
|
try:
|
||||||
|
return function(*args, **kw)
|
||||||
|
finally:
|
||||||
|
if patched:
|
||||||
|
DirectorySandbox._violation = DirectorySandbox._old
|
||||||
|
del DirectorySandbox._old
|
||||||
|
|
||||||
|
return __no_sandbox
|
||||||
|
|
||||||
|
@_no_sandbox
|
||||||
def _rename_path(path):
|
def _rename_path(path):
|
||||||
new_name = path + '.OLD.%s' % time.time()
|
new_name = path + '.OLD.%s' % time.time()
|
||||||
log.warn('Renaming %s into %s', path, new_name)
|
log.warn('Renaming %s into %s', path, new_name)
|
||||||
try:
|
|
||||||
from setuptools.sandbox import DirectorySandbox
|
|
||||||
def _violation(*args):
|
|
||||||
pass
|
|
||||||
DirectorySandbox._violation = _violation
|
|
||||||
except ImportError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
os.rename(path, new_name)
|
os.rename(path, new_name)
|
||||||
return new_name
|
return new_name
|
||||||
|
|
||||||
|
|
||||||
def _remove_flat_installation(placeholder):
|
def _remove_flat_installation(placeholder):
|
||||||
if not os.path.isdir(placeholder):
|
if not os.path.isdir(placeholder):
|
||||||
log.warn('Unkown installation at %s', placeholder)
|
log.warn('Unkown installation at %s', placeholder)
|
||||||
|
@ -273,22 +291,26 @@ def _after_install(dist):
|
||||||
placeholder = dist.get_command_obj('install').install_purelib
|
placeholder = dist.get_command_obj('install').install_purelib
|
||||||
_create_fake_setuptools_pkg_info(placeholder)
|
_create_fake_setuptools_pkg_info(placeholder)
|
||||||
|
|
||||||
|
@_no_sandbox
|
||||||
def _create_fake_setuptools_pkg_info(placeholder):
|
def _create_fake_setuptools_pkg_info(placeholder):
|
||||||
if not placeholder or not os.path.exists(placeholder):
|
if not placeholder or not os.path.exists(placeholder):
|
||||||
log.warn('Could not find the install location')
|
log.warn('Could not find the install location')
|
||||||
return
|
return
|
||||||
pyver = '%s.%s' % (sys.version_info[0], sys.version_info[1])
|
pyver = '%s.%s' % (sys.version_info[0], sys.version_info[1])
|
||||||
setuptools_file = 'setuptools-0.6c9-py%s.egg-info' % pyver
|
setuptools_file = 'setuptools-%s-py%s.egg-info' % \
|
||||||
|
(SETUPTOOLS_FAKED_VERSION, pyver)
|
||||||
pkg_info = os.path.join(placeholder, setuptools_file)
|
pkg_info = os.path.join(placeholder, setuptools_file)
|
||||||
if os.path.exists(pkg_info):
|
if os.path.exists(pkg_info):
|
||||||
log.warn('%s already exists', pkg_info)
|
log.warn('%s already exists', pkg_info)
|
||||||
return
|
return
|
||||||
|
|
||||||
log.warn('Creating %s', pkg_info)
|
log.warn('Creating %s', pkg_info)
|
||||||
f = open(pkg_info, 'w')
|
f = open(pkg_info, 'w')
|
||||||
try:
|
try:
|
||||||
f.write(SETUPTOOLS_PKG_INFO)
|
f.write(SETUPTOOLS_PKG_INFO)
|
||||||
finally:
|
finally:
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
pth_file = os.path.join(placeholder, 'setuptools.pth')
|
pth_file = os.path.join(placeholder, 'setuptools.pth')
|
||||||
log.warn('Creating %s', pth_file)
|
log.warn('Creating %s', pth_file)
|
||||||
f = open(pth_file, 'w')
|
f = open(pth_file, 'w')
|
||||||
|
@ -297,7 +319,6 @@ def _create_fake_setuptools_pkg_info(placeholder):
|
||||||
finally:
|
finally:
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
|
|
||||||
def _patch_egg_dir(path):
|
def _patch_egg_dir(path):
|
||||||
# let's check if it's already patched
|
# let's check if it's already patched
|
||||||
pkg_info = os.path.join(path, 'EGG-INFO', 'PKG-INFO')
|
pkg_info = os.path.join(path, 'EGG-INFO', 'PKG-INFO')
|
||||||
|
@ -319,7 +340,7 @@ def _patch_egg_dir(path):
|
||||||
|
|
||||||
def _before_install():
|
def _before_install():
|
||||||
log.warn('Before install bootstrap.')
|
log.warn('Before install bootstrap.')
|
||||||
fake_setuptools()
|
_fake_setuptools()
|
||||||
|
|
||||||
|
|
||||||
def _under_prefix(location):
|
def _under_prefix(location):
|
||||||
|
@ -340,7 +361,7 @@ def _under_prefix(location):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def fake_setuptools():
|
def _fake_setuptools():
|
||||||
log.warn('Scanning installed packages')
|
log.warn('Scanning installed packages')
|
||||||
try:
|
try:
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
import parser
|
|
||||||
|
try:
|
||||||
|
import parser
|
||||||
|
except ImportError:
|
||||||
|
parser = None
|
||||||
|
|
||||||
d={}
|
d={}
|
||||||
# d is the dictionary of unittest changes, keyed to the old name
|
# d is the dictionary of unittest changes, keyed to the old name
|
||||||
|
|
|
@ -523,7 +523,8 @@ class FormattedExcinfo(object):
|
||||||
source = py.code.Source("???")
|
source = py.code.Source("???")
|
||||||
line_index = 0
|
line_index = 0
|
||||||
else:
|
else:
|
||||||
line_index = entry.lineno - entry.getfirstlinesource()
|
# entry.getfirstlinesource() can be -1, should be 0 on jython
|
||||||
|
line_index = entry.lineno - max(entry.getfirstlinesource(), 0)
|
||||||
|
|
||||||
lines = []
|
lines = []
|
||||||
if self.style == "long":
|
if self.style == "long":
|
||||||
|
|
|
@ -353,6 +353,8 @@ def parse_time_with_missing_year(timestr):
|
||||||
day = time.strptime(tparts.pop(0), '%d')[2]
|
day = time.strptime(tparts.pop(0), '%d')[2]
|
||||||
last = tparts.pop(0) # year or hour:minute
|
last = tparts.pop(0) # year or hour:minute
|
||||||
try:
|
try:
|
||||||
|
if ":" in last:
|
||||||
|
raise ValueError()
|
||||||
year = time.strptime(last, '%Y')[0]
|
year = time.strptime(last, '%Y')[0]
|
||||||
hour = minute = 0
|
hour = minute = 0
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
|
|
@ -100,7 +100,7 @@ def raises(ExpectedException, *args, **kwargs):
|
||||||
k = ", ".join(["%s=%r" % x for x in kwargs.items()])
|
k = ", ".join(["%s=%r" % x for x in kwargs.items()])
|
||||||
if k:
|
if k:
|
||||||
k = ', ' + k
|
k = ', ' + k
|
||||||
expr = '%s(%r%s)' %(func.__name__, args, k)
|
expr = '%s(%r%s)' %(getattr(func, '__name__', func), args, k)
|
||||||
raise ExceptionFailure(msg="DID NOT RAISE",
|
raise ExceptionFailure(msg="DID NOT RAISE",
|
||||||
expr=args, expected=ExpectedException)
|
expr=args, expected=ExpectedException)
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import py
|
||||||
|
py.test.importorskip("parser")
|
||||||
from py._cmdline.pyconvert_unittest import rewrite_utest
|
from py._cmdline.pyconvert_unittest import rewrite_utest
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,8 @@ import py
|
||||||
from py._code.code import FormattedExcinfo, ReprExceptionInfo
|
from py._code.code import FormattedExcinfo, ReprExceptionInfo
|
||||||
queue = py.builtin._tryimport('queue', 'Queue')
|
queue = py.builtin._tryimport('queue', 'Queue')
|
||||||
|
|
||||||
|
failsonjython = py.test.mark.xfail("sys.platform.startswith('java')")
|
||||||
|
|
||||||
class TWMock:
|
class TWMock:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.lines = []
|
self.lines = []
|
||||||
|
@ -82,6 +84,7 @@ class TestTraceback_f_g_h:
|
||||||
assert s.startswith("def f():")
|
assert s.startswith("def f():")
|
||||||
assert s.endswith("raise ValueError")
|
assert s.endswith("raise ValueError")
|
||||||
|
|
||||||
|
@failsonjython
|
||||||
def test_traceback_entry_getsource_in_construct(self):
|
def test_traceback_entry_getsource_in_construct(self):
|
||||||
source = py.code.Source("""\
|
source = py.code.Source("""\
|
||||||
def xyz():
|
def xyz():
|
||||||
|
@ -216,7 +219,7 @@ def test_excinfo_repr():
|
||||||
def test_excinfo_str():
|
def test_excinfo_str():
|
||||||
excinfo = py.test.raises(ValueError, h)
|
excinfo = py.test.raises(ValueError, h)
|
||||||
s = str(excinfo)
|
s = str(excinfo)
|
||||||
assert s.startswith(__file__[:-1]) # pyc file
|
assert s.startswith(__file__[:-9]) # pyc file and $py.class
|
||||||
assert s.endswith("ValueError")
|
assert s.endswith("ValueError")
|
||||||
assert len(s.split(":")) >= 3 # on windows it's 4
|
assert len(s.split(":")) >= 3 # on windows it's 4
|
||||||
|
|
||||||
|
@ -290,6 +293,7 @@ class TestFormattedExcinfo:
|
||||||
assert lines[0] == "| def f(x):"
|
assert lines[0] == "| def f(x):"
|
||||||
assert lines[1] == " pass"
|
assert lines[1] == " pass"
|
||||||
|
|
||||||
|
@failsonjython
|
||||||
def test_repr_source_excinfo(self):
|
def test_repr_source_excinfo(self):
|
||||||
""" check if indentation is right """
|
""" check if indentation is right """
|
||||||
pr = FormattedExcinfo()
|
pr = FormattedExcinfo()
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
import sys
|
|
||||||
import py
|
|
|
@ -2,6 +2,8 @@ from py.code import Source
|
||||||
import py
|
import py
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
failsonjython = py.test.mark.xfail("sys.platform.startswith('java')")
|
||||||
|
|
||||||
def test_source_str_function():
|
def test_source_str_function():
|
||||||
x = Source("3")
|
x = Source("3")
|
||||||
assert str(x) == "3"
|
assert str(x) == "3"
|
||||||
|
@ -78,6 +80,7 @@ def test_source_strip_multiline():
|
||||||
source2 = source.strip()
|
source2 = source.strip()
|
||||||
assert source2.lines == [" hello"]
|
assert source2.lines == [" hello"]
|
||||||
|
|
||||||
|
@failsonjython
|
||||||
def test_syntaxerror_rerepresentation():
|
def test_syntaxerror_rerepresentation():
|
||||||
ex = py.test.raises(SyntaxError, py.code.compile, 'x x')
|
ex = py.test.raises(SyntaxError, py.code.compile, 'x x')
|
||||||
assert ex.value.lineno == 1
|
assert ex.value.lineno == 1
|
||||||
|
@ -129,6 +132,7 @@ class TestSourceParsingAndCompiling:
|
||||||
exec (co, d)
|
exec (co, d)
|
||||||
assert d['x'] == 3
|
assert d['x'] == 3
|
||||||
|
|
||||||
|
@failsonjython
|
||||||
def test_compile_and_getsource_simple(self):
|
def test_compile_and_getsource_simple(self):
|
||||||
co = py.code.compile("x=3")
|
co = py.code.compile("x=3")
|
||||||
exec (co)
|
exec (co)
|
||||||
|
@ -199,6 +203,7 @@ class TestSourceParsingAndCompiling:
|
||||||
assert isinstance(mod, ast.Module)
|
assert isinstance(mod, ast.Module)
|
||||||
compile(mod, "<filename>", "exec")
|
compile(mod, "<filename>", "exec")
|
||||||
|
|
||||||
|
@failsonjython
|
||||||
def test_compile_and_getsource(self):
|
def test_compile_and_getsource(self):
|
||||||
co = self.source.compile()
|
co = self.source.compile()
|
||||||
py.builtin.exec_(co, globals())
|
py.builtin.exec_(co, globals())
|
||||||
|
@ -255,6 +260,7 @@ def test_getstartingblock_multiline():
|
||||||
l = [i for i in x.source.lines if i.strip()]
|
l = [i for i in x.source.lines if i.strip()]
|
||||||
assert len(l) == 4
|
assert len(l) == 4
|
||||||
|
|
||||||
|
@failsonjython
|
||||||
def test_getline_finally():
|
def test_getline_finally():
|
||||||
def c(): pass
|
def c(): pass
|
||||||
excinfo = py.test.raises(TypeError, """
|
excinfo = py.test.raises(TypeError, """
|
||||||
|
@ -268,6 +274,7 @@ def test_getline_finally():
|
||||||
source = excinfo.traceback[-1].statement
|
source = excinfo.traceback[-1].statement
|
||||||
assert str(source).strip() == 'c(1)'
|
assert str(source).strip() == 'c(1)'
|
||||||
|
|
||||||
|
@failsonjython
|
||||||
def test_getfuncsource_dynamic():
|
def test_getfuncsource_dynamic():
|
||||||
source = """
|
source = """
|
||||||
def f():
|
def f():
|
||||||
|
@ -334,6 +341,7 @@ def test_getsource_fallback():
|
||||||
src = getsource(x)
|
src = getsource(x)
|
||||||
assert src == expected
|
assert src == expected
|
||||||
|
|
||||||
|
@failsonjython
|
||||||
def test_idem_compile_and_getsource():
|
def test_idem_compile_and_getsource():
|
||||||
from py._code.source import getsource
|
from py._code.source import getsource
|
||||||
expected = "def x(): pass"
|
expected = "def x(): pass"
|
||||||
|
@ -347,6 +355,7 @@ def test_findsource_fallback():
|
||||||
assert 'test_findsource_simple' in str(src)
|
assert 'test_findsource_simple' in str(src)
|
||||||
assert src[lineno] == ' def x():'
|
assert src[lineno] == ' def x():'
|
||||||
|
|
||||||
|
@failsonjython
|
||||||
def test_findsource___source__():
|
def test_findsource___source__():
|
||||||
from py._code.source import findsource
|
from py._code.source import findsource
|
||||||
co = py.code.compile("""if 1:
|
co = py.code.compile("""if 1:
|
||||||
|
@ -364,6 +373,7 @@ def test_findsource___source__():
|
||||||
assert src[lineno] == " def x():"
|
assert src[lineno] == " def x():"
|
||||||
|
|
||||||
|
|
||||||
|
@failsonjython
|
||||||
def test_getfslineno():
|
def test_getfslineno():
|
||||||
from py.code import getfslineno
|
from py.code import getfslineno
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
import os, sys
|
import os, sys
|
||||||
import py
|
import py
|
||||||
|
|
||||||
|
needsdup = py.test.mark.skipif("not hasattr(os, 'dup')")
|
||||||
|
|
||||||
from py.builtin import print_
|
from py.builtin import print_
|
||||||
|
|
||||||
if sys.version_info >= (3,0):
|
if sys.version_info >= (3,0):
|
||||||
|
@ -72,6 +74,7 @@ def pytest_funcarg__tmpfile(request):
|
||||||
request.addfinalizer(f.close)
|
request.addfinalizer(f.close)
|
||||||
return f
|
return f
|
||||||
|
|
||||||
|
@needsdup
|
||||||
def test_dupfile(tmpfile):
|
def test_dupfile(tmpfile):
|
||||||
somefile = tmpfile
|
somefile = tmpfile
|
||||||
flist = []
|
flist = []
|
||||||
|
@ -91,6 +94,8 @@ def test_dupfile(tmpfile):
|
||||||
somefile.close()
|
somefile.close()
|
||||||
|
|
||||||
class TestFDCapture:
|
class TestFDCapture:
|
||||||
|
pytestmark = needsdup
|
||||||
|
|
||||||
def test_stdout(self, tmpfile):
|
def test_stdout(self, tmpfile):
|
||||||
fd = tmpfile.fileno()
|
fd = tmpfile.fileno()
|
||||||
cap = py.io.FDCapture(fd)
|
cap = py.io.FDCapture(fd)
|
||||||
|
@ -261,6 +266,8 @@ class TestStdCapture:
|
||||||
assert not err
|
assert not err
|
||||||
|
|
||||||
class TestStdCaptureFD(TestStdCapture):
|
class TestStdCaptureFD(TestStdCapture):
|
||||||
|
pytestmark = needsdup
|
||||||
|
|
||||||
def getcapture(self, **kw):
|
def getcapture(self, **kw):
|
||||||
return py.io.StdCaptureFD(**kw)
|
return py.io.StdCaptureFD(**kw)
|
||||||
|
|
||||||
|
@ -289,6 +296,7 @@ class TestStdCaptureFD(TestStdCapture):
|
||||||
assert out.startswith("3")
|
assert out.startswith("3")
|
||||||
assert err.startswith("4")
|
assert err.startswith("4")
|
||||||
|
|
||||||
|
@needsdup
|
||||||
def test_capture_no_sys():
|
def test_capture_no_sys():
|
||||||
capsys = py.io.StdCapture()
|
capsys = py.io.StdCapture()
|
||||||
try:
|
try:
|
||||||
|
@ -303,6 +311,7 @@ def test_capture_no_sys():
|
||||||
finally:
|
finally:
|
||||||
capsys.reset()
|
capsys.reset()
|
||||||
|
|
||||||
|
@needsdup
|
||||||
def test_callcapture_nofd():
|
def test_callcapture_nofd():
|
||||||
def func(x, y):
|
def func(x, y):
|
||||||
oswritebytes(1, "hello")
|
oswritebytes(1, "hello")
|
||||||
|
|
|
@ -38,9 +38,12 @@ def test_terminalwriter_dumb_term_no_markup(monkeypatch):
|
||||||
def isatty(self):
|
def isatty(self):
|
||||||
return True
|
return True
|
||||||
monkeypatch.setattr(sys, 'stdout', MyFile())
|
monkeypatch.setattr(sys, 'stdout', MyFile())
|
||||||
assert sys.stdout.isatty()
|
try:
|
||||||
tw = py.io.TerminalWriter()
|
assert sys.stdout.isatty()
|
||||||
assert not tw.hasmarkup
|
tw = py.io.TerminalWriter()
|
||||||
|
assert not tw.hasmarkup
|
||||||
|
finally:
|
||||||
|
monkeypatch.undo()
|
||||||
|
|
||||||
def test_unicode_encoding():
|
def test_unicode_encoding():
|
||||||
msg = py.builtin._totext('b\u00f6y', 'utf8')
|
msg = py.builtin._totext('b\u00f6y', 'utf8')
|
||||||
|
|
|
@ -117,7 +117,7 @@ class TestLogConsumer:
|
||||||
|
|
||||||
def test_log_file(self, tmpdir):
|
def test_log_file(self, tmpdir):
|
||||||
customlog = tmpdir.join('log.out')
|
customlog = tmpdir.join('log.out')
|
||||||
py.log.setconsumer("default", open(str(customlog), 'w', buffering=1))
|
py.log.setconsumer("default", open(str(customlog), 'w', 1))
|
||||||
py.log.Producer("default")("hello world #1")
|
py.log.Producer("default")("hello world #1")
|
||||||
assert customlog.readlines() == ['[default] hello world #1\n']
|
assert customlog.readlines() == ['[default] hello world #1\n']
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,12 @@ class TestSvnURLCommandPath(CommonSvnTests):
|
||||||
def test_load(self, path1):
|
def test_load(self, path1):
|
||||||
super(TestSvnURLCommandPath, self).test_load(path1)
|
super(TestSvnURLCommandPath, self).test_load(path1)
|
||||||
|
|
||||||
|
# the following two work on jython but not in local/svnwc
|
||||||
|
def test_listdir(self, path1):
|
||||||
|
super(TestSvnURLCommandPath, self).test_listdir(path1)
|
||||||
|
def test_visit_ignore(self, path1):
|
||||||
|
super(TestSvnURLCommandPath, self).test_visit_ignore(path1)
|
||||||
|
|
||||||
def test_svnurl_needs_arg(self, path1):
|
def test_svnurl_needs_arg(self, path1):
|
||||||
py.test.raises(TypeError, "py.path.svnurl()")
|
py.test.raises(TypeError, "py.path.svnurl()")
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import py
|
import py
|
||||||
import sys
|
import os, sys
|
||||||
from py._plugin.pytest__pytest import HookRecorder
|
from py._plugin.pytest__pytest import HookRecorder
|
||||||
from py._test.pluginmanager import Registry
|
from py._test.pluginmanager import Registry
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ def test_hookrecorder_basic():
|
||||||
|
|
||||||
def test_hookrecorder_basic_no_args_hook():
|
def test_hookrecorder_basic_no_args_hook():
|
||||||
rec = HookRecorder(Registry())
|
rec = HookRecorder(Registry())
|
||||||
apimod = type(sys)('api')
|
apimod = type(os)('api')
|
||||||
def xyz():
|
def xyz():
|
||||||
pass
|
pass
|
||||||
apimod.xyz = xyz
|
apimod.xyz = xyz
|
||||||
|
|
|
@ -82,7 +82,7 @@ class TestTerminal:
|
||||||
])
|
])
|
||||||
|
|
||||||
def test_collect_fail(self, testdir, option):
|
def test_collect_fail(self, testdir, option):
|
||||||
p = testdir.makepyfile("import xyz")
|
p = testdir.makepyfile("import xyz\n")
|
||||||
result = testdir.runpytest(*option._getcmdargs())
|
result = testdir.runpytest(*option._getcmdargs())
|
||||||
result.stdout.fnmatch_lines([
|
result.stdout.fnmatch_lines([
|
||||||
"*test_collect_fail.py E*",
|
"*test_collect_fail.py E*",
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
import py
|
import py
|
||||||
import sys, os
|
import sys, os
|
||||||
|
|
||||||
|
def fass():
|
||||||
|
assert 1 == 2
|
||||||
def check_assertion():
|
def check_assertion():
|
||||||
excinfo = py.test.raises(AssertionError, "assert 1 == 2")
|
excinfo = py.test.raises(AssertionError, fass)
|
||||||
s = excinfo.exconly(tryshort=True)
|
s = excinfo.exconly(tryshort=True)
|
||||||
if not s == "assert 1 == 2":
|
if not s == "assert 1 == 2":
|
||||||
raise ValueError("assertion not enabled: got %s" % s)
|
raise ValueError("assertion not enabled: got %s" % s)
|
||||||
|
@ -16,6 +18,7 @@ def test_invoke_assertion(recwarn, monkeypatch):
|
||||||
py.magic.revoke(assertion=True)
|
py.magic.revoke(assertion=True)
|
||||||
recwarn.pop(DeprecationWarning)
|
recwarn.pop(DeprecationWarning)
|
||||||
|
|
||||||
|
@py.test.mark.skipif("sys.platform.startswith('java')")
|
||||||
def test_invoke_compile(recwarn, monkeypatch):
|
def test_invoke_compile(recwarn, monkeypatch):
|
||||||
monkeypatch.setattr(py.builtin.builtins, 'compile', None)
|
monkeypatch.setattr(py.builtin.builtins, 'compile', None)
|
||||||
py.magic.invoke(compile=True)
|
py.magic.invoke(compile=True)
|
||||||
|
|
|
@ -9,7 +9,7 @@ def checksubpackage(name):
|
||||||
keys = dir(obj)
|
keys = dir(obj)
|
||||||
assert len(keys) > 0
|
assert len(keys) > 0
|
||||||
print (obj.__map__)
|
print (obj.__map__)
|
||||||
for name in obj.__map__:
|
for name in list(obj.__map__):
|
||||||
assert hasattr(obj, name), (obj, name)
|
assert hasattr(obj, name), (obj, name)
|
||||||
|
|
||||||
def test_dir():
|
def test_dir():
|
||||||
|
|
|
@ -15,6 +15,16 @@ class TestRaises:
|
||||||
def test_raises_function(self):
|
def test_raises_function(self):
|
||||||
py.test.raises(ValueError, int, 'hello')
|
py.test.raises(ValueError, int, 'hello')
|
||||||
|
|
||||||
|
def test_raises_callable_no_exception(self):
|
||||||
|
from py._test.outcome import ExceptionFailure
|
||||||
|
class A:
|
||||||
|
def __call__(self):
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
py.test.raises(ValueError, A())
|
||||||
|
except ExceptionFailure:
|
||||||
|
pass
|
||||||
|
|
||||||
def test_pytest_exit():
|
def test_pytest_exit():
|
||||||
try:
|
try:
|
||||||
py.test.exit("hello")
|
py.test.exit("hello")
|
||||||
|
@ -68,5 +78,7 @@ def test_pytest_cmdline_main(testdir):
|
||||||
py.test.cmdline.main([__file__])
|
py.test.cmdline.main([__file__])
|
||||||
""" % (str(py._pydir.dirpath())))
|
""" % (str(py._pydir.dirpath())))
|
||||||
import subprocess
|
import subprocess
|
||||||
ret = subprocess.call([sys.executable, str(p)])
|
popen = subprocess.Popen([sys.executable, str(p)], stdout=subprocess.PIPE)
|
||||||
|
s = popen.stdout.read()
|
||||||
|
ret = popen.wait()
|
||||||
assert ret == 0
|
assert ret == 0
|
||||||
|
|
Loading…
Reference in New Issue