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") self.trace = TagTracer().get("pluginmanage")
if os.environ.get('PYTEST_DEBUG'): if os.environ.get('PYTEST_DEBUG'):
err = sys.stderr err = sys.stderr
if hasattr(os, 'dup'): encoding = getattr(err, 'encoding', 'utf8')
err = py.io.dupfile(err) try:
err = py.io.dupfile(err, encoding=encoding)
except Exception:
pass
self.trace.root.setwriter(err.write) self.trace.root.setwriter(err.write)
self.hook = HookRelay([hookspec], pm=self) self.hook = HookRelay([hookspec], pm=self)
self.register(self) self.register(self)

View File

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

View File

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

View File

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

View File

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

View File

@ -40,6 +40,17 @@ class TestParseIni:
"*tox.ini:2*requires*9.0*actual*" "*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: class TestConfigCmdlineParsing:
def test_parsing_again_fails(self, testdir): def test_parsing_again_fails(self, testdir):
config = testdir.reparseconfig([testdir.tmpdir]) config = testdir.reparseconfig([testdir.tmpdir])