|
| 1 | +import checkpy.tests as t |
| 2 | +import checkpy.lib as lib |
| 3 | +import checkpy.assertlib as asserts |
| 4 | + |
| 5 | +import hashlib |
| 6 | + |
| 7 | +from _extensions import * |
| 8 | + |
| 9 | +def sandbox(): |
| 10 | + lib.require("climate.txt", "https://raw.githubusercontent.com/minprog/pyprog/2022/opdrachten/week5/eca2csv/climate.txt") |
| 11 | + |
| 12 | +@t.test(1) |
| 13 | +def output_test(test): |
| 14 | + def testMethod(): |
| 15 | + output = lib.outputOf(test.fileName, overwriteAttributes = [("__name__", "__main__")]).strip() |
| 16 | + with open('climate-noheader.txt') as cnh: |
| 17 | + hash = hashlib.md5(cnh.read().strip().encode('utf-8')).hexdigest() |
| 18 | + if hash != 'a9c7b2346db2f89eedb77e8915f583c5': |
| 19 | + return False, f"'climate-noheader.txt' does not contain exactly what is expected" |
| 20 | + with open('climate-noheader-no2020.txt') as cnh: |
| 21 | + hash = hashlib.md5(cnh.read().strip().encode('utf-8')).hexdigest() |
| 22 | + if hash != '87defdce3b585d4fe3d59be8a07d61e1': |
| 23 | + return False, f"'climate-noheader-no2020.txt' does not contain exactly what is expected" |
| 24 | + with open('climate-cleaned.txt') as cnh: |
| 25 | + hash = hashlib.md5(cnh.read().strip().encode('utf-8')).hexdigest() |
| 26 | + if hash != 'aa7138f0b4e8eb25a5982afe21ef79f0': |
| 27 | + return False, f"'climate-cleaned.txt' does not contain exactly what is expected" |
| 28 | + with open('climate.csv') as cnh: |
| 29 | + hash = hashlib.md5(cnh.read().strip().encode('utf-8')).hexdigest() |
| 30 | + if hash != '1ed8ae701fd107d64a35f1e0e8abfefd': |
| 31 | + return False, f"'climate.csv' does not contain exactly what is expected" |
| 32 | + return True |
| 33 | + test.test = testMethod |
| 34 | + test.description = lambda : "prints exactly the right output" |
0 commit comments