Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(22)

Unified Diff: Lib/test/test_reprlib.py

Issue 10639: reindent.py converts newlines to platform default
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Lib/test/test_raise.py ('k') | Lib/test/test_robotparser.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Lib/test/test_reprlib.py Tue Jul 26 09:37:46 2011 +0300
+++ b/Lib/test/test_reprlib.py Mon Jul 25 09:47:18 2011 -0400
@@ -8,7 +8,7 @@
import shutil
import unittest
-from test.support import run_unittest, create_empty_file
+from test.support import run_unittest
from reprlib import repr as r # Don't shadow builtin repr
from reprlib import Repr
from reprlib import recursive_repr
@@ -193,9 +193,10 @@
r(y)
r(z)
-def write_file(path, text):
- with open(path, 'w', encoding='ASCII') as fp:
- fp.write(text)
+def touch(path, text=''):
+ fp = open(path, 'w')
+ fp.write(text)
+ fp.close()
class LongReprTest(unittest.TestCase):
def setUp(self):
@@ -205,10 +206,10 @@
# Make the package and subpackage
shutil.rmtree(self.pkgname, ignore_errors=True)
os.mkdir(self.pkgname)
- create_empty_file(os.path.join(self.pkgname, '__init__.py'))
+ touch(os.path.join(self.pkgname, '__init__.py'))
shutil.rmtree(self.subpkgname, ignore_errors=True)
os.mkdir(self.subpkgname)
- create_empty_file(os.path.join(self.subpkgname, '__init__.py'))
+ touch(os.path.join(self.subpkgname, '__init__.py'))
# Remember where we are
self.here = os.getcwd()
sys.path.insert(0, self.here)
@@ -230,7 +231,7 @@
def test_module(self):
eq = self.assertEqual
- create_empty_file(os.path.join(self.subpkgname, self.pkgname + '.py'))
+ touch(os.path.join(self.subpkgname, self.pkgname + '.py'))
from areallylongpackageandmodulenametotestreprtruncation.areallylongpackageandmodulenametotestreprtruncation import areallylongpackageandmodulenametotestreprtruncation
eq(repr(areallylongpackageandmodulenametotestreprtruncation),
"<module %r from %r>" % (areallylongpackageandmodulenametotestreprtruncation.__name__, areallylongpackageandmodulenametotestreprtruncation.__file__))
@@ -238,7 +239,7 @@
def test_type(self):
eq = self.assertEqual
- write_file(os.path.join(self.subpkgname, 'foo.py'), '''\
+ touch(os.path.join(self.subpkgname, 'foo.py'), '''\
class foo(object):
pass
''')
@@ -252,7 +253,7 @@
pass
def test_class(self):
- write_file(os.path.join(self.subpkgname, 'bar.py'), '''\
+ touch(os.path.join(self.subpkgname, 'bar.py'), '''\
class bar:
pass
''')
@@ -261,7 +262,7 @@
self.assertEqual(repr(bar.bar), "<class '%s.bar'>" % bar.__name__)
def test_instance(self):
- write_file(os.path.join(self.subpkgname, 'baz.py'), '''\
+ touch(os.path.join(self.subpkgname, 'baz.py'), '''\
class baz:
pass
''')
@@ -272,7 +273,7 @@
def test_method(self):
eq = self.assertEqual
- write_file(os.path.join(self.subpkgname, 'qux.py'), '''\
+ touch(os.path.join(self.subpkgname, 'qux.py'), '''\
class aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:
def amethod(self): pass
''')
« no previous file with comments | « Lib/test/test_raise.py ('k') | Lib/test/test_robotparser.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+