Permalink
Browse files

fix resource warnings in tests

  • Loading branch information...
1 parent c5f2782 commit 615b0940d1c3edff8f11dcec6e46f0960e9d8d72 @scoder scoder committed Dec 15, 2012
Showing with 9 additions and 3 deletions.
  1. +9 −3 selftest2.py
View
@@ -126,14 +126,18 @@ def parsefile():
here; by default, the 'parse' function opens the file in binary
mode, and doctest doesn't filter out carriage returns.
- >>> tree = ElementTree.parse(open("samples/simple.xml", "rb"))
+ >>> file = open("samples/simple.xml", "rb")
+ >>> tree = ElementTree.parse(file)
+ >>> file.close()
>>> tree.write(stdout())
<root>
<element key="value">text</element>
<element>text</element>tail
<empty-element/>
</root>
- >>> tree = ElementTree.parse(open("samples/simple-ns.xml", "rb"))
+ >>> file = open("samples/simple-ns.xml", "rb")
+ >>> tree = ElementTree.parse(file)
+ >>> file.close()
>>> tree.write(stdout())
<root xmlns="http://namespace/">
<element key="value">text</element>
@@ -396,7 +400,8 @@ def makeelement():
## >>> builder = ElementTree.TreeBuilder()
## >>> builder.addobserver(observer)
## >>> parser = ElementTree.XMLParser(builder)
-## >>> parser.feed(open("samples/simple.xml", "rb").read())
+## >>> file = open("samples/simple.xml", "rb")
+## >>> parser.feed(file.read())
## start root
## start element
## end element
@@ -405,6 +410,7 @@ def makeelement():
## start empty-element
## end empty-element
## end root
+## >>> file.close()
## """

0 comments on commit 615b094

Please sign in to comment.