示例#1
0
 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
示例#2
0
 def test_str(self):
     assert str(ClientException()) == ""
     assert str(ClientException("error message")) == "error message"
示例#3
0
 def test_inheritance(self):
     assert isinstance(ClientException(), PRAWException)
示例#4
0
 def test_str(self):
     assert str(ClientException()) == ''
     assert str(ClientException('error message')) == 'error message'