Skip to content

Commit

Permalink
Merge pull request #177 from cs50/develop
Browse files Browse the repository at this point in the history
v3.0.8
  • Loading branch information
Kareem Zidane authored Aug 20, 2019
2 parents a1de91a + 5e0d3a1 commit 9f0fe31
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion check50/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def excepthook(cls, exc, tb):
if excepthook.verbose:
traceback.print_exception(cls, exc, tb)
if hasattr(exc, "payload"):
print("Exception payload:", exc.payload)
print("Exception payload:", json.dumps(exc.payload), sep="\n")

sys.exit(1)

Expand Down
14 changes: 10 additions & 4 deletions check50/_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ def stdout(self, output=None, str_output=None, regex=True, timeout=3):
result += self.process.after
raise Mismatch(str_output, result.replace("\r\n", "\n"))
except TIMEOUT:
raise Failure(_("did not find \"{}\"").format(_raw(str_output)))
raise Failure(_("did not find {}").format(_raw(str_output)))
except UnicodeDecodeError:
raise Failure(_("output not valid ASCII text"))
except Exception:
Expand Down Expand Up @@ -402,7 +402,14 @@ class Mismatch(Failure):
"""

def __init__(self, expected, actual, help=None):
super().__init__(rationale=_("expected \"{}\", not \"{}\"").format(_raw(expected), _raw(actual)), help=help)
super().__init__(rationale=_("expected {}, not {}").format(_raw(expected), _raw(actual)), help=help)

if expected == EOF:
expected = "EOF"

if actual == EOF:
actual = "EOF"

self.payload.update({"expected": expected, "actual": actual})


Expand Down Expand Up @@ -445,8 +452,7 @@ def _raw(s):
if s == EOF:
return "EOF"

s = repr(s) # Get raw representation of string
s = s[1:-1] # Strip away quotation marks
s = f'"{repr(s)[1:-1]}"'
if len(s) > 15:
s = s[:15] + "..." # Truncate if too long
return s
Expand Down
8 changes: 4 additions & 4 deletions check50/_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ def _run(arg):

def _stdin(arg):
if isinstance(arg, list):
arg = r"\n".join(arg)
arg = r"\n".join(str(a) for a in arg)

arg = arg.replace("\n", r"\n").replace("\t", r"\t").replace('"', '\"')
arg = str(arg).replace("\n", r"\n").replace("\t", r"\t").replace('"', '\"')
return f'.stdin("{arg}", prompt=False)'


def _stdout(arg):
if isinstance(arg, list):
arg = r"\n".join(arg)
arg = arg.replace("\n", r"\n").replace("\t", r"\t").replace('"', '\"')
arg = r"\n".join(str(a) for a in arg)
arg = str(arg).replace("\n", r"\n").replace("\t", r"\t").replace('"', '\"')
return f'.stdout("{arg}", regex=False)'


Expand Down
4 changes: 0 additions & 4 deletions check50/renderer/_renderers.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import json
import pathlib

import attr
import jinja2
import pkg_resources
from pexpect.exceptions import EOF
import termcolor

from ..runner import CheckResult

TEMPLATES = pathlib.Path(pkg_resources.resource_filename("check50.renderer", "templates"))


Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@
"console_scripts": ["check50=check50.__main__:main"]
},
url="https://github.com/cs50/check50",
version="3.0.7",
version="3.0.8",
include_package_data=True
)

0 comments on commit 9f0fe31

Please sign in to comment.