@@ -32,18 +32,21 @@ def test_check_template(self):
3232 assert attrib .check_template ('template_string' ) == None
3333 assert attrib .check_template ('{{template_string' ) == (1 ,
3434 "unexpected end of template, expected 'end of print statement'." ,)
35- template = open (get_test_loc ('attrib_gen/test.template' )).read ()
35+ with open (get_test_loc ('attrib_gen/test.template' )) as tmpl :
36+ template = tmpl .read ()
3637 assert attrib .check_template (template ) == None
3738
3839 def test_check_template_default_is_valid (self ):
39- template = open (attrib .default_template ).read ()
40+ with open (attrib .default_template ) as tmpl :
41+ template = tmpl .read ()
4042 assert attrib .check_template (template ) == None
4143
4244 def test_generate (self ):
4345 expected = (u'Apache HTTP Server: 2.4.3\n '
4446 u'resource: httpd-2.4.3.tar.gz\n ' )
4547 test_file = get_test_loc ('attrib_gen/attrib.ABOUT' )
46- template = open (get_test_loc ('attrib_gen/test.template' )).read ()
48+ with open (get_test_loc ('attrib_gen/test.template' )) as tmpl :
49+ template = tmpl .read ()
4750 _errors , abouts = model .collect_inventory (test_file )
4851 result = attrib .generate (abouts , template )
4952 self .assertEqual (expected , result )
@@ -52,6 +55,7 @@ def test_generate_from_file_with_default_template(self):
5255 test_file = get_test_loc ('attrib_gen/attrib.ABOUT' )
5356 _errors , abouts = model .collect_inventory (test_file )
5457 result = attrib .generate_from_file (abouts )
55- expected = unicode (open (get_test_loc ('attrib_gen/expected_default_attrib.html' )).read ())
58+ with open (get_test_loc ('attrib_gen/expected_default_attrib.html' )) as exp :
59+ expected = unicode (exp .read ())
5660 self .assertEqual ([x .rstrip () for x in expected .splitlines ()],
5761 [x .rstrip () for x in result .splitlines ()])
0 commit comments