Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add local testing capability #12

Open
rahuldave opened this issue May 23, 2019 · 2 comments
Open

Add local testing capability #12

rahuldave opened this issue May 23, 2019 · 2 comments

Comments

@rahuldave
Copy link

I was looking to test python code locally. There is a conftest.py in the spacy course which could be used as a start, but the testing in this repo does not have that support. So i created a file which has the following hacky code

from wasabi import Printer
import sys

with(open(sys.argv[1])) as fd:
    thesolution = fd.read()
with(open(sys.argv[2])) as fd:
    thetest = fd.read()

__msg__ = Printer()
__solution__ = """{}""".format(thesolution)

exec(thesolution)

exec(thetest)

print(globals().keys())
try:
    test()
except AssertionError as e:
    __msg__.fail(e)

The advantage of this repo's mechanism is that only wasabi needs to be there on the binder server for testing. But if we want to test with data and then need to put the full repo on binder (rather than just a shadow binder repo/branch with maybe a data folder), then additional stuff for pytest does not seem a large imposition?

@rahuldave
Copy link
Author

rahuldave commented May 23, 2019

One additional thought: pylint/flake8 the student submission. Then "in solution" type tests need not worry about whitespace and stuff.

@ines
Copy link
Owner

ines commented May 27, 2019

Not 100% sure I understand the question – but you should be able to port over the conftest.py from my spaCy course repo and then run pytest. The conftest will take care of putting together the tests using the solution code and test file, and run them accordingly.

One additional thought: pylint/flake8 the student submission. Then "in solution" type tests need not worry about whitespace and stuff.

Yes, I'd use black for that: https://github.com/python/black

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants