Example #1
0
 def call2(self, *args):
     for arg in args:
         self.assertTrue(is_fsnative(arg))
     old_stdout = sys.stdout
     old_stderr = sys.stderr
     try:
         out = StringIO()
         err = StringIO()
         sys.stdout = out
         sys.stderr = err
         try:
             ret = self._main([fsnative(self.TOOL_NAME)] + list(args))
         except SystemExit as e:
             ret = e.code
         ret = ret or 0
         out_val = out.getvalue()
         err_val = err.getvalue()
         if os.name == "nt" and PY2:
             encoding = getattr(sys.stdout, "encoding", None) or "utf-8"
             out_val = text_type(out_val, encoding)
             err_val = text_type(err_val, encoding)
         return (ret, out_val, err_val)
     finally:
         sys.stdout = old_stdout
         sys.stderr = old_stderr
Example #2
0
import re
import glob
import os
import sys
import unittest

from unittest import TestCase as BaseTestCase

from mutagen._compat import PY3
from mutagen._toolsutil import fsencoding, is_fsnative


DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "data")
if os.name == "nt" and not PY3:
    DATA_DIR = DATA_DIR.decode("ascii")
assert is_fsnative(DATA_DIR)


if os.name != "nt":
    try:
        u"öäü".encode(fsencoding())
    except ValueError:
        raise RuntimeError("This test suite needs a unicode locale encoding. "
                           "Try setting LANG=C.UTF-8")


class TestCase(BaseTestCase):

    def failUnlessRaisesRegexp(self, exc, re_, fun, *args, **kwargs):
        def wrapped(*args, **kwargs):
            try: