diff --git a/AUTHORS b/AUTHORS index 8cc6824cd..e966139be 100644 --- a/AUTHORS +++ b/AUTHORS @@ -44,6 +44,7 @@ David Mohr David Vierra Diego Russo Dmitry Dygalo +Duncan Betts Edison Gustavo Muenz Edoardo Batini Eduardo Schettino diff --git a/CHANGELOG.rst b/CHANGELOG.rst index f97ff3787..40797c30c 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,7 +1,7 @@ 3.0.5.dev0 ========== -* +* Add hint to error message hinting possible missing __init__.py (`#478`_). Thanks `@DuncanBetts`_. * An error message is now displayed if ``--confcutdir`` is not a valid directory, avoiding subtle bugs (`#2078`_). @@ -20,8 +20,10 @@ * .. _@adler-j: https://github.com/adler-j +.. _@DuncanBetts: https://github.com/DuncanBetts .. _@nedbat: https://github.com/nedbat +.. _#478: https://github.com/pytest-dev/pytest/issues/478 .. _#2038: https://github.com/pytest-dev/pytest/issues/2038 .. _#2078: https://github.com/pytest-dev/pytest/issues/2078 .. _#2082: https://github.com/pytest-dev/pytest/issues/2082 diff --git a/_pytest/main.py b/_pytest/main.py index 5771a1699..dd0775501 100644 --- a/_pytest/main.py +++ b/_pytest/main.py @@ -704,10 +704,9 @@ class Session(FSCollector): path = self.config.invocation_dir.join(relpath, abs=True) if not path.check(): if self.config.option.pyargs: - msg = "file or package not found: " + raise pytest.UsageError("file or package not found: " + arg + " (missing __init__.py?)") else: - msg = "file not found: " - raise pytest.UsageError(msg + arg) + raise pytest.UsageError("file not found: " + arg) parts[0] = path return parts