def test_word_length(word: str, requested_length, expected_length) -> bool: """Check that word lenths are as expected. Requesting a word less than 3 chars long should fail. """ print(f"testing: word:{word}, " f"requested_length:{requested_length}, " f"expected_length:{expected_length}") if type(requested_length) is str and word is not None: print( "This API returns a random word if you malform the url\n", "You'll need to typecheck the input. I.e. check\n", "if type(length) is int:\n", "....#and so on\n", "It also does the same thing if you go under 3 characters\n", "long, so remember to check for that too!", ) print(grumpy()) if expected_length is None and word is None: return True if word is None: return False if len(word) == requested_length and len(word) == expected_length: return True print("Something a bit odd is happening") print(grumpy()) return False
def test_diagrams(diagram, expected): """Test, crudely, that the correct diagram is being returned.""" if expected == "tall" and "\\" in diagram: return True if expected == "wide" and "∕" in diagram: return True if expected == "equal" and "⋱" in diagram: return True print(grumpy()) return False
def test_diagrams(diagram, expected) -> bool: """Test, crudely, that the correct diagram is being returned.""" # print("testing", diagram, expected) if diagram and expected: if expected == "tall" and ("\\" in diagram): return True if expected == "wide" and "∕" in diagram: return True if expected == "equal" and "⋱" in diagram: return True print("failure in test_diagrams", "\n", grumpy()) return False