Browse files

Close open test files

  • Loading branch information...
1 parent c52e800 commit cd7997d770f12690afd563bd339667cc58bc2c28 @miso-belica miso-belica committed Mar 20, 2013
Showing with 6 additions and 4 deletions.
  1. +6 −4 test.py
View
10 test.py
@@ -25,11 +25,13 @@ def __init__(self, file_name, encoding):
def runTest(self):
u = UniversalDetector()
- for line in open(self.file_name, 'rb'):
- u.feed(line)
- if u.done:
- break
+ with open(self.file_name, 'rb') as file:
+ for line in file:
+ u.feed(line)
+ if u.done:
+ break
u.close()
+
self.assertEqual(u.result['encoding'].lower(), self.encoding,
"Expected %s, but got %r in %s" %
(self.encoding, u.result['encoding'],

0 comments on commit cd7997d

Please sign in to comment.