Last active
January 27, 2016 15:01
-
-
Save mokevnin/3e29f26bfde04ef1588e to your computer and use it in GitHub Desktop.
python handler for battle.hexlet.io
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import atexit | |
import fileinput | |
import os | |
import json | |
import unittest | |
class TestSolution(unittest.TestCase): | |
maxDiff = None | |
def test_solution(self): | |
checks = [json.loads(line) for line in fileinput.input()] | |
import solution | |
for check in checks: | |
expected = check['expected'] | |
arguments = check['arguments'] | |
if 'check' in check: | |
atexit.register(onexit, check['check']) | |
else: | |
msg = "Arguments was: %s" % arguments | |
self.assertEqual(expected, solution.solution(*arguments), msg) | |
def onexit(msg): | |
print(msg) | |
if __name__ == '__main__': | |
unittest.main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"expected": {"one": 5, "two": 5}, "arguments": [["one", "two"], 5]} | |
{"expected": {"one": 3}, "arguments": [["one"], 3]} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM hexlet/hexlet-base | |
RUN apt-install python-pip python-dev | |
RUN apt-install python3-pip python3-dev | |
RUN pip3 install pytest | |
ENV PYTHONDONTWRITEBYTECODE 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test: | |
@cat data.jsons | sudo -u nobody python3 checker.py | |
.PHONY: test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# BEGIN python3 | |
def solution(l, d): | |
return {v: d for v in l} | |
# END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment