summaryrefslogtreecommitdiff
path: root/functional_tests
diff options
context:
space:
mode:
authorJason Pellerin <jpellerin@gmail.com>2007-06-28 03:50:58 +0000
committerJason Pellerin <jpellerin@gmail.com>2007-06-28 03:50:58 +0000
commit2981bf9c478b9dcad3cbd7a4b56f01e3b47eecc2 (patch)
treec5007ac11cf6cdb4fd6fca0264a1a387b173cd8a /functional_tests
parent16c2dfbee39c993023ea758c09eda2bf692007cf (diff)
downloadnose-2981bf9c478b9dcad3cbd7a4b56f01e3b47eecc2.tar.gz
Added regression test for issue #3
Diffstat (limited to 'functional_tests')
-rw-r--r--functional_tests/support/gen/test.py12
-rw-r--r--functional_tests/test_loader.py19
2 files changed, 30 insertions, 1 deletions
diff --git a/functional_tests/support/gen/test.py b/functional_tests/support/gen/test.py
new file mode 100644
index 0000000..13a0c3e
--- /dev/null
+++ b/functional_tests/support/gen/test.py
@@ -0,0 +1,12 @@
+"""This test will fail if generators bind too early."""
+
+from nose.tools import eq_
+
+def test1():
+
+ def func(_l, _n):
+ eq_(len(_l), _n)
+ l = []
+ for i in xrange(5):
+ yield func, l, i
+ l.append(None)
diff --git a/functional_tests/test_loader.py b/functional_tests/test_loader.py
index 14cc00d..d80197f 100644
--- a/functional_tests/test_loader.py
+++ b/functional_tests/test_loader.py
@@ -377,7 +377,24 @@ class TestNoseTestLoader(unittest.TestCase):
print res.errors
assert res.errors, "Expected errors but got none"
assert not res.failures, res.failures
-
+
+ def test_generator_with_closure(self):
+ """Test that a generator test can employ a closure
+
+ Issue #3. If the generator binds early, the last value
+ of the closure will be seen for each generated test and
+ the tests will fail.
+ """
+ gen = os.path.join(support, 'gen')
+ l = loader.TestLoader(workingDir=gen)
+ suite = l.loadTestsFromName('test')
+ res = unittest._TextTestResult(
+ stream=unittest._WritelnDecorator(sys.stdout),
+ descriptions=0, verbosity=1)
+ suite(res)
+ assert not res.errors
+ self.assertEqual(res.testsRun, 5)
+
# used for comparing lists
def diff(a, b):