def test_encoding(self): root_dir = 'C:\\Temp\\TV' strings = [u'Les Enfants De La T\xe9l\xe9', u'RT� One'] app.SYS_ENCODING = None try: locale.setlocale(locale.LC_ALL, "") app.SYS_ENCODING = locale.getpreferredencoding() except (locale.Error, IOError): pass # For OSes that are poorly configured I'll just randomly force UTF-8 if not app.SYS_ENCODING or app.SYS_ENCODING in ('ANSI_X3.4-1968', 'US-ASCII', 'ASCII'): app.SYS_ENCODING = 'UTF-8' for test in strings: try: show_dir = os.path.join(root_dir, sanitize_filename(test)) self.assertTrue(isinstance(show_dir, text_type)) except Exception as error: # pylint: disable=broad-except ex(error)
def _connectivity_test(): """Generate tests. :param self: :return: test to run """ if not _provider.url: print('%s has no url set, skipping' % _provider.name) return try: requests.head(_provider.url, verify=certifi.old_where(), timeout=10) except requests.exceptions.SSLError as error: if 'certificate verify failed' in str(error): print('Cannot verify certificate for %s' % _provider.name) else: print('SSLError on %s: %s' % (_provider.name, ex(error.message))) raise except requests.exceptions.Timeout: print('Provider timed out')
def test_ex_ret_stringed_args(self): self.assertEqual(ex(Exception(303)), 'error 303')
def test_ex_ret_concat_args_strings(self): self.assertEqual(ex(Exception('lots', 'of', 'strings')), 'lots : of : strings')
def test_ex_ret_args_ustring(self): self.assertEqual(ex(Exception('\xc3\xa4h')), u'äh')
def test_ex_ret_args_string(self): self.assertEqual(ex(Exception('hi')), 'hi')
def test_args_of_none_returns_empty(self): self.assertEqual(ex(Exception(None, None)), u'')
def test_empty_args_returns_empty(self): self.assertEqual(ex(Exception()), u'')
def test_none_returns_empty(self): self.assertEqual(ex(None), u'')