summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--functional_tests/doc_tests/test_init_plugin/init_plugin.rst8
-rw-r--r--functional_tests/doc_tests/test_multiprocess/support/test_shared.py11
-rw-r--r--functional_tests/doc_tests/test_xunit_plugin/test_skips.rst4
-rw-r--r--functional_tests/test_entrypoints.py7
-rw-r--r--unit_tests/test_xunit.py3
5 files changed, 23 insertions, 10 deletions
diff --git a/functional_tests/doc_tests/test_init_plugin/init_plugin.rst b/functional_tests/doc_tests/test_init_plugin/init_plugin.rst
index 6c64029..d89bfa4 100644
--- a/functional_tests/doc_tests/test_init_plugin/init_plugin.rst
+++ b/functional_tests/doc_tests/test_init_plugin/init_plugin.rst
@@ -138,18 +138,20 @@ specify a configuration file on the command line:
To use the plugin, we need a config file.
>>> import os
- >>> cfg_file = os.path.join(os.path.dirname(__file__), 'example.cfg')
- >>> bytes = open(cfg_file, 'w').write("""\
+ >>> cfg_path = os.path.join(os.path.dirname(__file__), 'example.cfg')
+ >>> cfg_file = open(cfg_path, 'w')
+ >>> bytes = cfg_file.write("""\
... [DEFAULT]
... can_frobnicate = 1
... likes_cheese = 0
... """)
+ >>> cfg_file.close()
Now we can execute a test run using that configuration, after first
resetting the widget system to an unconfigured state.
>>> ConfigurableWidget.cfg = None
- >>> argv = [__file__, '-v', '--widget-config', cfg_file]
+ >>> argv = [__file__, '-v', '--widget-config', cfg_path]
>>> run(argv=argv, suite=suite(),
... plugins=[BetterConfiguringPlugin()]) # doctest: +REPORT_NDIFF
Widgets can frobnicate (or not) ... ok
diff --git a/functional_tests/doc_tests/test_multiprocess/support/test_shared.py b/functional_tests/doc_tests/test_multiprocess/support/test_shared.py
index d8617f8..d798aac 100644
--- a/functional_tests/doc_tests/test_multiprocess/support/test_shared.py
+++ b/functional_tests/doc_tests/test_multiprocess/support/test_shared.py
@@ -17,9 +17,14 @@ def _clear():
if os.path.isfile(flag):
os.unlink(flag)
-
+
def logged():
- return [line for line in open(flag, 'r')]
+ flag_file = open(flag, 'r')
+ try:
+ lines = [line for line in flag_file]
+ finally:
+ flag_file.close()
+ return lines
def setup():
@@ -31,7 +36,7 @@ def teardown():
print >> sys.stderr, "teardown called"
_clear()
-
+
def test_a():
assert len(logged()) == 1, "len(%s) !=1" % called
diff --git a/functional_tests/doc_tests/test_xunit_plugin/test_skips.rst b/functional_tests/doc_tests/test_xunit_plugin/test_skips.rst
index dd0590e..4a8aa3d 100644
--- a/functional_tests/doc_tests/test_xunit_plugin/test_skips.rst
+++ b/functional_tests/doc_tests/test_xunit_plugin/test_skips.rst
@@ -36,5 +36,7 @@ Ran 4 tests in ...s
<BLANKLINE>
FAILED (SKIP=1, errors=1, failures=1)
->>> open(outfile, 'r').read() # doctest: +ELLIPSIS
+>>> result_file = open(outfile, 'r')
+>>> result_file.read() # doctest: +ELLIPSIS
'<?xml version="1.0" encoding="UTF-8"?><testsuite name="nosetests" tests="4" errors="1" failures="1" skip="1"><testcase classname="test_skip" name="test_ok" time="..."></testcase><testcase classname="test_skip" name="test_err" time="..."><error type="...Exception" message="oh no">...</error></testcase><testcase classname="test_skip" name="test_fail" time="..."><failure type="...AssertionError" message="bye">...</failure></testcase><testcase classname="test_skip" name="test_skip" time="..."><skipped type="...SkipTest" message="not me">...</skipped></testcase></testsuite>'
+>>> result_file.close()
diff --git a/functional_tests/test_entrypoints.py b/functional_tests/test_entrypoints.py
index a57f218..5bc9646 100644
--- a/functional_tests/test_entrypoints.py
+++ b/functional_tests/test_entrypoints.py
@@ -13,5 +13,8 @@ ep = os.path.join(support, 'ep')
def test_plugin_entrypoint_is_loadable():
- epfile = os.path.join(ep, 'Some_plugin.egg-info', 'entry_points.txt')
- assert EntryPoint.parse_map(open(epfile, 'r').readlines())
+ ep_path = os.path.join(ep, 'Some_plugin.egg-info', 'entry_points.txt')
+ ep_file = open(ep_path, 'r')
+ lines = ep_file.readlines()
+ ep_file.close()
+ assert EntryPoint.parse_map(lines)
diff --git a/unit_tests/test_xunit.py b/unit_tests/test_xunit.py
index 95ff9e3..c141739 100644
--- a/unit_tests/test_xunit.py
+++ b/unit_tests/test_xunit.py
@@ -131,8 +131,9 @@ class TestXMLOutputWithXML(unittest.TestCase):
pass
self.x.report(DummyStream())
f = open(self.xmlfile, 'rb')
- return f.read()
+ data = f.read()
f.close()
+ return data
def test_addFailure(self):
test = mktest()