Skip to content

Commit

Permalink
Close open test files
Browse files Browse the repository at this point in the history
  • Loading branch information
miso-belica committed Mar 20, 2013
1 parent c52e800 commit cd7997d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions test.py
Expand Up @@ -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'],
Expand Down

0 comments on commit cd7997d

Please sign in to comment.