diff --git a/pytest/main.py b/pytest/main.py index 3d8e08a00..84e9bdc6b 100644 --- a/pytest/main.py +++ b/pytest/main.py @@ -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) diff --git a/pytest/plugin/session.py b/pytest/plugin/session.py index a7c3a4724..524f34c77 100644 --- a/pytest/plugin/session.py +++ b/pytest/plugin/session.py @@ -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__": diff --git a/pytest/plugin/unittest.py b/pytest/plugin/unittest.py index 476fcb325..b903927c6 100644 --- a/pytest/plugin/unittest.py +++ b/pytest/plugin/unittest.py @@ -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): diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index 3f3f977c5..e8acf7837 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -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) diff --git a/testing/test_collection.py b/testing/test_collection.py index 6e983e157..451279ac4 100644 --- a/testing/test_collection.py +++ b/testing/test_collection.py @@ -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(): diff --git a/testing/test_config.py b/testing/test_config.py index 391238419..b835d9613 100644 --- a/testing/test_config.py +++ b/testing/test_config.py @@ -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])