From 58c6971dc8488e7648ae7e4783e5682c84fab874 Mon Sep 17 00:00:00 2001 From: holger krekel Date: Thu, 6 Aug 2009 15:26:45 +0200 Subject: [PATCH] nicer error message for non-collectable test files / items fixes issue #27 --HG-- branch : 1.0.x --- CHANGELOG | 5 ++++- py/test/collect.py | 7 ++----- py/test/testing/acceptance_test.py | 9 +++++++++ 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index fb5f0d506..d7e06d730 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -5,7 +5,10 @@ Changes between 1.0.0 and 1.0.1 work within tests, they are encoded as "utf8" by default, terminalwriting was adapted and somewhat unified between windows and linux -* terser reporting of collection error tracebacks, now skips py-internals +* fix issue #27: better reporting on non-collectable items given on commandline + (e.g. pyc files) + +* terser reporting of collection error tracebacks * renaming of arguments to some special rather internal hooks diff --git a/py/test/collect.py b/py/test/collect.py index e1fbdd505..8a2e9467b 100644 --- a/py/test/collect.py +++ b/py/test/collect.py @@ -167,16 +167,13 @@ class Node(object): if colitem.fspath == fspath or colitem.name == basename: l.append(colitem) if not l: - msg = ("Collector %r does not provide %r colitem " - "existing colitems are: %s" % - (cur, fspath, colitems)) - raise AssertionError(msg) + raise self.config.Error("can't collect: %s" %(fspath,)) if basenames: if len(l) > 1: msg = ("Collector %r has more than one %r colitem " "existing colitems are: %s" % (cur, fspath, colitems)) - raise AssertionError(msg) + raise self.config.Error("xxx-too many test types for: %s" % (fspath, )) cur = l[0] else: if len(l) > 1: diff --git a/py/test/testing/acceptance_test.py b/py/test/testing/acceptance_test.py index 41d0066b6..c96c65185 100644 --- a/py/test/testing/acceptance_test.py +++ b/py/test/testing/acceptance_test.py @@ -67,3 +67,12 @@ class TestGeneralUsage: "E ImportError: No module named does_not_work", ]) assert result.ret == 1 + + def test_not_collectable_arguments(self, testdir): + p1 = testdir.makepyfile("") + p2 = testdir.makefile(".pyc", "123") + result = testdir.runpytest(p1, p2) + assert result.ret != 0 + assert result.stderr.fnmatch_lines([ + "*ERROR: can't collect: %s" %(p2,) + ])