summaryrefslogtreecommitdiff
path: root/functional_tests
diff options
context:
space:
mode:
authorJohn Szakmeister <john@szakmeister.net>2013-02-08 13:26:45 -0800
committerJohn Szakmeister <john@szakmeister.net>2013-02-08 13:26:45 -0800
commita4f18c870f7641b76e921d47f9b0f23c7c557561 (patch)
tree88ad21d823e4e70d9de93d9a92cf69e5830e256d /functional_tests
parentbf15e81b114a9256fb2de7afc6507e2258a4150b (diff)
parent1ccf676bf39ca27cc39a599a6e55681752ce8685 (diff)
downloadnose-a4f18c870f7641b76e921d47f9b0f23c7c557561.tar.gz
Merge pull request #607 from jszakmeister/fix-resource-warnings
Fix most resource warnings under 3.2 and 3.3.
Diffstat (limited to 'functional_tests')
-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
4 files changed, 21 insertions, 9 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)