Spruced up verify-manifest.py

This commit is contained in:
Jeppe Klitgaard committed 2015-04-06 00:53:23 +02:00
1 parent 9a45eec450
commit c35a887e1a
2 files changed
+20 -21

No files matched your search

+19 -21
View File
@@ -1,34 +1,32 @@
import subprocess """
Exits with exit code 0 if manifest was verified.
"""
from sh import check_manifest
from sh import ErrorReturnCode_1
import sys import sys
EXPECTED_OUTPUT = "lists of files in version control and sdist match" EXPECTED_OUTPUT = "lists of files in version control and sdist match"
def check_manifest(): def verify_manifest():
""" """
Returns a tuple containing ``(output, status)``. Returns a ``str`` containing output from ``check-manifest``.
Status is:
``True`` if ``output`` was as expected (no errors),
``False`` otherwise.
""" """
output = subprocess.check_output(["check-manifest"]).decode() try:
if EXPECTED_OUTPUT == output.strip(): output = check_manifest().decode()
status = True except ErrorReturnCode_1 as e:
else: output = e.stderr.decode() + e.stdout.decode()
status = False
return (output, status) return output
if __name__ == '__main__': if __name__ == '__main__':
output, verified = check_manifest() output = verify_manifest()
if not verified: print(output)
print("Check-manifest didn't match.")
print("OUTPUT: {}".format(output)) if output == EXPECTED_OUTPUT:
print("EXPECTED_OUTPUT: {}".format(EXPECTED_OUTPUT)) sys.exit(0)
sys.exit(1)
else: else:
print("Manifest verified.") sys.exit(1)
sys.exit(0)
+1
View File
@@ -70,6 +70,7 @@ commands =
basepython = python3.4 basepython = python3.4
deps = deps =
check-manifest check-manifest
sh
commands = commands =
python {toxinidir}/bin/verify-manifest.py python {toxinidir}/bin/verify-manifest.py