Last active
June 10, 2020 19:59
-
-
Save huntfx/ae66267cae9a119837f46a68e43947f9 to your computer and use it in GitHub Desktop.
This file contains 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
"""Grab the test count and grader setup from the EdX Python exercises.""" | |
import os | |
import sys | |
mod = __import__(sys.argv[1][:-3]) | |
def __fn__(*args, **kwargs): | |
print('Number of tests:', len(mod.grader.tests())) | |
print() | |
print(sys.argv[1] + ':') | |
with open(os.path.join(os.getcwd(), sys.argv[1]), 'r') as f: | |
lines = [' ' + line.rstrip() for line in f] | |
for line in lines[:-1]: | |
print(line) | |
return lines[-1] # Return the final line so function based executions don't print None | |
if hasattr(mod, 'fn'): | |
globals()[mod.fn] = __fn__ | |
else: | |
print(func()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment