some python3 related fixes

This commit is contained in:
holger krekel 2010-11-07 01:10:15 +01:00
parent 8716b391c7
commit d9ad2e7cce
6 changed files with 27 additions and 6 deletions

View File

@ -68,8 +68,11 @@ class PluginManager(object):
self.trace = TagTracer().get("pluginmanage")
if os.environ.get('PYTEST_DEBUG'):
err = sys.stderr
if hasattr(os, 'dup'):
err = py.io.dupfile(err)
encoding = getattr(err, 'encoding', 'utf8')
try:
err = py.io.dupfile(err, encoding=encoding)
except Exception:
pass
self.trace.root.setwriter(err.write)
self.hook = HookRelay([hookspec], pm=self)
self.register(self)

View File

@ -437,7 +437,7 @@ class Collection(FSCollector):
def _tryconvertpyarg(self, x):
try:
mod = __import__(x, None, None, ['__doc__'])
except ImportError:
except (ValueError, ImportError):
return x
p = py.path.local(mod.__file__)
if p.purebasename == "__init__":

View File

@ -33,6 +33,10 @@ class UnitTestCase(py.test.collect.Class):
meth()
class TestCaseFunction(py.test.collect.Function):
def setup(self):
pass
def teardown(self):
pass
def startTest(self, testcase):
pass
def addError(self, testcase, rawexcinfo):

View File

@ -325,6 +325,11 @@ class TestInvocationVariants:
result.stdout.fnmatch_lines([
"*1 passed*"
])
result = testdir.runpytest("--pyargs", ".")
assert result.ret == 0
result.stdout.fnmatch_lines([
"*2 passed*"
])
def test_cmdline_python_package_not_exists(self, testdir):
result = testdir.runpytest("--pyargs", "tpkgwhatv")
@ -342,7 +347,7 @@ class TestInvocationVariants:
def test_hello(self):
assert self.attr
class RealTest(TestHello, unittest.TestCase):
class RealTest(unittest.TestCase, TestHello):
attr = 42
""")
reprec = testdir.inline_run(testpath)

View File

@ -496,8 +496,6 @@ class Test_getinitialnodes:
config = testdir.reparseconfig([x])
col = testdir.getnode(config, x)
assert isinstance(col, py.test.collect.Module)
print col.obj
print col.listchain()
assert col.name == 'subdir/x.py'
assert col.parent.parent is None
for col in col.listchain():

View File

@ -40,6 +40,17 @@ class TestParseIni:
"*tox.ini:2*requires*9.0*actual*"
])
@py.test.mark.xfail(reason="probably not needed")
def test_confcutdir(self, testdir):
sub = testdir.mkdir("sub")
sub.chdir()
testdir.makeini("""
[pytest]
addopts = --qwe
""")
result = testdir.runpytest("--confcutdir=.")
assert result.ret == 0
class TestConfigCmdlineParsing:
def test_parsing_again_fails(self, testdir):
config = testdir.reparseconfig([testdir.tmpdir])