Exemplo n.º 1
0
    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)
Exemplo n.º 2
0
    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')
Exemplo n.º 3
0
 def test_ex_ret_stringed_args(self):
     self.assertEqual(ex(Exception(303)), 'error 303')
Exemplo n.º 4
0
 def test_ex_ret_concat_args_strings(self):
     self.assertEqual(ex(Exception('lots', 'of', 'strings')),
                      'lots : of : strings')
Exemplo n.º 5
0
 def test_ex_ret_args_ustring(self):
     self.assertEqual(ex(Exception('\xc3\xa4h')), u'äh')
Exemplo n.º 6
0
 def test_ex_ret_args_string(self):
     self.assertEqual(ex(Exception('hi')), 'hi')
Exemplo n.º 7
0
 def test_args_of_none_returns_empty(self):
     self.assertEqual(ex(Exception(None, None)), u'')
Exemplo n.º 8
0
 def test_empty_args_returns_empty(self):
     self.assertEqual(ex(Exception()), u'')
Exemplo n.º 9
0
 def test_none_returns_empty(self):
     self.assertEqual(ex(None), u'')