[Pytest-commit] commit/tox: Anthon van der Neut: issue_1_empty_setup_py: fix for issue #1: Empty setup.py leads to very obscure error
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Wed Aug 14 09:58:16 CEST 2013
1 new commit in tox:
https://bitbucket.org/hpk42/tox/commits/4414956b0a64/
Changeset: 4414956b0a64
User: Anthon van der Neut
Date: 2013-08-14 08:57:10
Summary: issue_1_empty_setup_py: fix for issue #1: Empty setup.py leads to very obscure error
This was caused by no dist directory being created and listing
that directory raising an exception.
- added some test for setup.py:
- empty
- only start of line comment
- some code, but no setup()
- on error finding the dist
- check if empty or comment only setup.py: msg that setup.py is empty
- msg to check 'python setup.py sdist' by hand
Affected #: 2 files
diff -r 2f81a12f84bc87215c4c5862c3555111b5ab1991 -r 4414956b0a64281d79e3fcd986516df154f6efe1 tests/test_z_cmdline.py
--- a/tests/test_z_cmdline.py
+++ b/tests/test_z_cmdline.py
@@ -269,6 +269,54 @@
result = cmd.run("tox", )
assert result.ret == 0
+def test_minimal_setup_py_empty(cmd, initproj):
+ initproj("pkg123-0.7", filedefs={
+ 'tests': {'test_hello.py': "def test_hello(): pass"},
+ 'setup.py': """
+ """
+ ,
+ 'tox.ini': ''
+
+ })
+ result = cmd.run("tox", )
+ assert result.ret == 1
+ result.stdout.fnmatch_lines([
+ "*ERROR*empty*",
+ ])
+
+def test_minimal_setup_py_comment_only(cmd, initproj):
+ initproj("pkg123-0.7", filedefs={
+ 'tests': {'test_hello.py': "def test_hello(): pass"},
+ 'setup.py': """\n# some comment
+
+ """
+ ,
+ 'tox.ini': ''
+
+ })
+ result = cmd.run("tox", )
+ assert result.ret == 1
+ result.stdout.fnmatch_lines([
+ "*ERROR*empty*",
+ ])
+
+def test_minimal_setup_py_non_functional(cmd, initproj):
+ initproj("pkg123-0.7", filedefs={
+ 'tests': {'test_hello.py': "def test_hello(): pass"},
+ 'setup.py': """
+ import sys
+
+ """
+ ,
+ 'tox.ini': ''
+
+ })
+ result = cmd.run("tox", )
+ assert result.ret == 1
+ result.stdout.fnmatch_lines([
+ "*ERROR*check setup.py*",
+ ])
+
def test_sdist_fails(cmd, initproj):
initproj("pkg123-0.7", filedefs={
'tests': {'test_hello.py': "def test_hello(): pass"},
diff -r 2f81a12f84bc87215c4c5862c3555111b5ab1991 -r 4414956b0a64281d79e3fcd986516df154f6efe1 tox/_cmdline.py
--- a/tox/_cmdline.py
+++ b/tox/_cmdline.py
@@ -321,7 +321,27 @@
action.popen([sys.executable, setup, "sdist", "--formats=zip",
"--dist-dir", self.config.distdir, ],
cwd=self.config.setupdir)
- return self.config.distdir.listdir()[0]
+ try:
+ return self.config.distdir.listdir()[0]
+ except py.error.ENOENT:
+ # check if empty or comment only
+ data = []
+ with open(str(setup)) as fp:
+ for line in fp:
+ if line and line[0] == '#':
+ continue
+ data.append(line)
+ if not ''.join(data).strip():
+ self.report.error(
+ 'setup.py is empty'
+ )
+ raise SystemExit(1)
+ self.report.error(
+ 'No dist directory found. Please check setup.py, e.g with:\n'\
+ ' python setup.py sdist'
+ )
+ raise SystemExit(1)
+
def make_emptydir(self, path):
if path.check():
Repository URL: https://bitbucket.org/hpk42/tox/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the pytest-commit
mailing list