changeset 118:e738d6fe5f3f 1.1

tests: make the tests work under Pypy (issue3965) ..which needs explicit close() due to lack of reference counting.
author Matt Mackall <mpm@selenic.com>
date Sun, 23 Jun 2013 17:52:16 -0500
parents 59cb26bf866e
children c13b99b01008
files tests/test-config.py tests/test-import.py tests/test-paths.py tests/test-update.py
diffstat 4 files changed, 18 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/tests/test-config.py	Fri Jun 14 18:36:56 2013 +0300
+++ b/tests/test-config.py	Sun Jun 23 17:52:16 2013 -0500
@@ -3,7 +3,9 @@
 class test_config(common.basetest):
     def setUp(self):
         common.basetest.setUp(self)
-        open('.hg/hgrc', 'a').write('[section]\nkey=value\n')
+        f = open('.hg/hgrc', 'a')
+        f.write('[section]\nkey=value\n')
+        f.close()
         self.client = hglib.open()
 
     def test_basic(self):
--- a/tests/test-import.py	Fri Jun 14 18:36:56 2013 +0300
+++ b/tests/test-import.py	Sun Jun 23 17:52:16 2013 -0500
@@ -22,7 +22,9 @@
         self.assertEquals(self.client.cat(['a']), '1\n')
 
     def test_basic_file(self):
-        open('patch', 'wb').write(patch)
+        f = open('patch', 'wb')
+        f.write(patch)
+        f.close()
 
         # --no-commit
         self.client.import_(['patch'], nocommit=True)
--- a/tests/test-paths.py	Fri Jun 14 18:36:56 2013 +0300
+++ b/tests/test-paths.py	Sun Jun 23 17:52:16 2013 -0500
@@ -3,7 +3,9 @@
 
 class test_paths(common.basetest):
     def test_basic(self):
-        open('.hg/hgrc', 'a').write('[paths]\nfoo = bar\n')
+        f = open('.hg/hgrc', 'a')
+        f.write('[paths]\nfoo = bar\n')
+        f.close()
 
         # hgrc isn't watched for changes yet, have to reopen
         self.client = hglib.open()
--- a/tests/test-update.py	Fri Jun 14 18:36:56 2013 +0300
+++ b/tests/test-update.py	Sun Jun 23 17:52:16 2013 -0500
@@ -33,7 +33,9 @@
         self.client.commit('fourth')
         self.client.update(rev2)
         old = open('a').read()
-        open('a', 'wb').write('a' + old)
+        f = open('a', 'wb')
+        f.write('a' + old)
+        f.close()
         u, m, r, ur = self.client.update()
         self.assertEquals(u, 0)
         self.assertEquals(m, 1)
@@ -68,12 +70,16 @@
         self.assertEquals(old, open('a').read())
 
     def test_basic_plain(self):
-        open('.hg/hgrc', 'a').write('[defaults]\nupdate=-v\n')
+        f = open('.hg/hgrc', 'a')
+        f.write('[defaults]\nupdate=-v\n')
+        f.close()
         self.test_basic()
 
     def test_largefiles(self):
         import os
-        open('.hg/hgrc', 'a').write('[extensions]\nlargefiles=\n')
+        f = open('.hg/hgrc', 'a')
+        f.write('[extensions]\nlargefiles=\n')
+        f.close()
         self.append('b', 'a')
         try:
             self.client.rawcommand(['add', 'b', '--large'])