diff options
author | Guido van Rossum <guido@python.org> | 2007-10-26 04:29:23 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2007-10-26 04:29:23 (GMT) |
commit | c12a813aa7671ee12ccb79a70177a62bcefa2561 (patch) | |
tree | f6512593e7c4ed8211f2dd2c34c8676b5ed6301e /Lib/test | |
parent | daa251ca097e7f7382ed57c10efbbaddad103afb (diff) | |
download | cpython-c12a813aa7671ee12ccb79a70177a62bcefa2561.zip cpython-c12a813aa7671ee12ccb79a70177a62bcefa2561.tar.gz cpython-c12a813aa7671ee12ccb79a70177a62bcefa2561.tar.bz2 |
Patch # 1331 by Christian Heimes.
The patch fixes some of the problems on Windows. It doesn't introduce
addition problems on Linux.
Diffstat (limited to 'Lib/test')
-rwxr-xr-x | Lib/test/regrtest.py | 1 | ||||
-rw-r--r-- | Lib/test/test_mailbox.py | 7 | ||||
-rw-r--r-- | Lib/test/test_netrc.py | 13 | ||||
-rw-r--r-- | Lib/test/test_pep277.py | 8 | ||||
-rw-r--r-- | Lib/test/test_subprocess.py | 4 |
5 files changed, 19 insertions, 14 deletions
diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py index 91728ef..d126854 100755 --- a/Lib/test/regrtest.py +++ b/Lib/test/regrtest.py @@ -885,6 +885,7 @@ _expectations = { test_pwd test_resource test_signal + test_syslog test_threadsignals test_wait3 test_wait4 diff --git a/Lib/test/test_mailbox.py b/Lib/test/test_mailbox.py index 0d22164..4345be7 100644 --- a/Lib/test/test_mailbox.py +++ b/Lib/test/test_mailbox.py @@ -58,6 +58,7 @@ class TestMailbox(TestBase): self._box = self._factory(self._path) def tearDown(self): + self._box.close() self._delete_recursively(self._path) def test_add(self): @@ -390,12 +391,14 @@ class TestMailbox(TestBase): self._box.add(contents[0]) self._box.add(contents[1]) self._box.add(contents[2]) + oldbox = self._box method() self._box = self._factory(self._path) keys = self._box.keys() self.assertEqual(len(keys), 3) for key in keys: self.assert_(self._box.get_string(key) in contents) + oldbox.close() def test_dump_message(self): # Write message representations to disk @@ -403,7 +406,7 @@ class TestMailbox(TestBase): _sample_message, io.StringIO(_sample_message)): output = io.StringIO() self._box._dump_message(input, output) - self.assert_(output.getvalue() == + self.assertEqual(output.getvalue(), _sample_message.replace('\n', os.linesep)) output = io.StringIO() self.assertRaises(TypeError, @@ -694,6 +697,7 @@ class TestMaildir(TestMailbox): class _TestMboxMMDF(TestMailbox): def tearDown(self): + self._box.close() self._delete_recursively(self._path) for lock_remnant in glob.glob(self._path + '.*'): test_support.unlink(lock_remnant) @@ -916,6 +920,7 @@ class TestBabyl(TestMailbox): _factory = lambda self, path, factory=None: mailbox.Babyl(path, factory) def tearDown(self): + self._box.close() self._delete_recursively(self._path) for lock_remnant in glob.glob(self._path + '.*'): test_support.unlink(lock_remnant) diff --git a/Lib/test/test_netrc.py b/Lib/test/test_netrc.py index b536255..4a2cb0d 100644 --- a/Lib/test/test_netrc.py +++ b/Lib/test/test_netrc.py @@ -21,25 +21,24 @@ temp_filename = test_support.TESTFN class NetrcTestCase(unittest.TestCase): - def setUp (self): + def setUp(self): mode = 'w' if sys.platform not in ['cygwin']: mode += 't' fp = open(temp_filename, mode) fp.write(TEST_NETRC) fp.close() - self.netrc = netrc.netrc(temp_filename) - def tearDown (self): - del self.netrc + def tearDown(self): os.unlink(temp_filename) def test_case_1(self): - self.assert_(self.netrc.macros == {'macro1':['line1\n', 'line2\n'], + nrc = netrc.netrc(temp_filename) + self.assert_(nrc.macros == {'macro1':['line1\n', 'line2\n'], 'macro2':['line3\n', 'line4\n']} ) - self.assert_(self.netrc.hosts['foo'] == ('log1', 'acct1', 'pass1')) - self.assert_(self.netrc.hosts['default'] == ('log2', None, 'pass2')) + self.assert_(nrc.hosts['foo'] == ('log1', 'acct1', 'pass1')) + self.assert_(nrc.hosts['default'] == ('log2', None, 'pass2')) def test_main(): test_support.run_unittest(NetrcTestCase) diff --git a/Lib/test/test_pep277.py b/Lib/test/test_pep277.py index 794de0d..554e011 100644 --- a/Lib/test/test_pep277.py +++ b/Lib/test/test_pep277.py @@ -36,7 +36,7 @@ class UnicodeFileTests(unittest.TestCase): except OSError: pass for name in self.files: - f = open(name, 'w') + f = open(name, 'wb') f.write((name+'\n').encode("utf-8")) f.close() os.stat(name) @@ -71,7 +71,7 @@ class UnicodeFileTests(unittest.TestCase): def test_open(self): for name in self.files: - f = open(name, 'w') + f = open(name, 'wb') f.write((name+'\n').encode("utf-8")) f.close() os.stat(name) @@ -80,7 +80,7 @@ class UnicodeFileTests(unittest.TestCase): f1 = os.listdir(test_support.TESTFN) # Printing f1 is not appropriate, as specific filenames # returned depend on the local encoding - f2 = os.listdir(str(test_support.TESTFN, + f2 = os.listdir(str(test_support.TESTFN.encode("utf-8"), sys.getfilesystemencoding())) f2.sort() print(f2) @@ -96,7 +96,7 @@ class UnicodeFileTests(unittest.TestCase): oldwd = os.getcwd() os.mkdir(dirname) os.chdir(dirname) - f = open(filename, 'w') + f = open(filename, 'wb') f.write((filename + '\n').encode("utf-8")) f.close() print(repr(filename)) diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py index fea98dc..39a889d 100644 --- a/Lib/test/test_subprocess.py +++ b/Lib/test/test_subprocess.py @@ -630,7 +630,7 @@ class ProcessTestCase(unittest.TestCase): p = subprocess.Popen(["set"], shell=1, stdout=subprocess.PIPE, env=newenv) - self.assertNotEqual(p.stdout.read().find("physalis"), -1) + self.assertNotEqual(p.stdout.read().find(b"physalis"), -1) def test_shell_string(self): # Run command through the shell (string) @@ -639,7 +639,7 @@ class ProcessTestCase(unittest.TestCase): p = subprocess.Popen("set", shell=1, stdout=subprocess.PIPE, env=newenv) - self.assertNotEqual(p.stdout.read().find("physalis"), -1) + self.assertNotEqual(p.stdout.read().find(b"physalis"), -1) def test_call_string(self): # call() function with string argument on Windows |