def validate_sub(self): self.VALID_SUB = False try: response = self.REDDIT_INSTANCE.subreddits.search_by_name( self.SUBREDDIT_NAME, exact=True) if len(response) == 0: raise ClientException("Invalid input, must not be empty") else: self.VALID_SUB = True # Only valid here, must not throw any Exception and must not be empty input except NotFound: self.VALID_SUB = False print( "This subreddit does not exist, make sure you input a valid subreddit" ) sys.exit(1) except Exception: print("Unexpected Error Occurred") raise
def test_str(self): assert str(ClientException()) == "" assert str(ClientException("error message")) == "error message"
def test_inheritance(self): assert isinstance(ClientException(), PRAWException)
def test_str(self): assert str(ClientException()) == '' assert str(ClientException('error message')) == 'error message'