class TestNsinstall(unittest.TestCase): """
Unit tests for nsinstall.py """
def setUp(self):
self.tmpdir = mkdtemp()
def tearDown(self): # Unicode strings means non-ASCII children can be deleted properly on # Windows if sys.stdin.encoding isNone:
tmpdir = six.ensure_text(self.tmpdir) else:
tmpdir = six.ensure_text(self.tmpdir, sys.stdin.encoding)
rmtree(tmpdir)
# utility methods for tests def touch(self, file, dir=None): if dir isNone:
dir = self.tmpdir
f = os.path.join(dir, file)
open(f, "w").close() return f
def mkdirs(self, dir):
d = os.path.join(self.tmpdir, dir)
os.makedirs(d) return d
def test_nsinstall_d(self): "Test that nsinstall -d works (create directories in target)" # -d makes no sense to me, but ok!
testfile = self.touch("testfile")
testdir = self.mkdirs("testdir")
destdir = os.path.join(testdir, "subdir")
self.assertEqual(nsinstall(["-d", testfile, destdir]), 0)
self.assert_(os.path.isdir(os.path.join(destdir, "testfile")))
# Executing nsinstall.py with python 2 is not supported.
@unittest.skipIf( not RUN_NON_ASCII_TESTS or sys.version_info[0] == 2, "Skipping non ascii tests"
) def test_nsinstall_non_ascii_subprocess(self): "Test that nsinstall as a subprocess handles non-ASCII files"
filename = "\u2325\u3452\u2415\u5081"
testfile = self.touch(filename)
testdir = self.mkdirs("\u4241\u1D04\u1414")
p = subprocess.Popen([sys.executable, NSINSTALL_PATH, testfile, testdir])
rv = p.wait()
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.