We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Test classes:
from checkpy import * Lexicon = (declarative.class_("Lexicon") .params("word_length") .method("get_word").params().returnType(str) ) Hangman = (declarative.class_("Hangman") .params("word", "number_of_guesses") .method("guess").params("letter").returnType(bool) .method("number_of_guesses").params().returnType(int) .method("won").params().returnType(bool) )
Then for checks:
testGuess = test()(Hangman .init("hello", 5) .method("number_of_guesses").call().returns(5) .method("guess").call("a").returns(False) .method("number_of_guesses").call().returns(4) .method("guess").call("e").returns(True) .method("number_of_guesses").call().returns(4) ) testWon = passed(testGuess)(Hangman .init("a", 1) .method("won").call().returns(False) .method("guess").call("a").returns(True) .method("won").call().returns(True) )
Mixing with @literal ?
@literal
globals_ = {"Hangman": Hangman, "Lexicon": Lexicon} @literal(globals=globals_) def testGuess(): """number of guesses decreases after incorrect guess""" hangman = Hangman("hello", 5) assert hangman.number_of_guesses() == 5 assert not hangman.guess("a") assert hangman.number_of_guesses() == 4 assert hangman.guess("e") assert hangman.number_of_guesses() == 4 @passed(testGuess) @literal(globals=globals_) def testWon(): """won() returns True after guessing the word""" hangman = Hangman("a", 1) assert not hangman.won() assert hangman.guess("a") assert hangman.won()
isinstance(Hangman, declarative.class_("Hangman")) should return True.
isinstance(Hangman, declarative.class_("Hangman"))
any attribute access on declarative.class_("Hangman") should be passed on to Hangman
declarative.class_("Hangman")
Hangman
globals should be inserted before import *, then overwritten after to ensure globals are set on import and not overwritten by the student. Like so:
import *
globalsCopy = deepcopy(globals) exec("from Hangman import *", globals=globals) globals.update(globalsCopy)
name mangling for methods defined on declarative.class_("Hangman") to prevent accidental calls from the student's code???
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Test classes:
Then for checks:
Mixing with
@literal
?isinstance(Hangman, declarative.class_("Hangman"))
should return True.any attribute access on
declarative.class_("Hangman")
should be passed on toHangman
globals should be inserted before
import *
, then overwritten after to ensure globals are set on import and not overwritten by the student. Like so:name mangling for methods defined on
declarative.class_("Hangman")
to prevent accidental calls from the student's code???The text was updated successfully, but these errors were encountered: