summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris McDonough <chrism@plope.com>2012-02-28 21:55:32 -0500
committerChris McDonough <chrism@plope.com>2012-02-28 21:55:32 -0500
commitbb388112f92943f8047ec40f74c90790b162f46d (patch)
treee5386a1a85b05175f8824b5e6c60379266e3f2dc
parentd5682595295a6054b8542b9d6e4443915b452b1f (diff)
downloadpyramid-bb388112f92943f8047ec40f74c90790b162f46d.tar.gz
pyramid-bb388112f92943f8047ec40f74c90790b162f46d.tar.bz2
pyramid-bb388112f92943f8047ec40f74c90790b162f46d.zip
close file before trying to reopen it on windows, preventing a test from failing
-rw-r--r--pyramid/tests/test_scripts/test_pserve.py22
1 files changed, 7 insertions, 15 deletions
diff --git a/pyramid/tests/test_scripts/test_pserve.py b/pyramid/tests/test_scripts/test_pserve.py
index 687fbd256..e21a703d9 100644
--- a/pyramid/tests/test_scripts/test_pserve.py
+++ b/pyramid/tests/test_scripts/test_pserve.py
@@ -1,5 +1,6 @@
import unittest
import os
+import tempfile
class TestPServeCommand(unittest.TestCase):
def setUp(self):
@@ -41,19 +42,14 @@ class TestPServeCommand(unittest.TestCase):
self.out_.getvalue(),'Not a valid PID file in %s' % path)
def test_run_stop_daemon_invalid_pid_in_file(self):
- import tempfile
- tmp = tempfile.NamedTemporaryFile()
- tmp.write(b'9999999')
- tmp.flush()
- tmpname = tmp.name
- inst = self._makeOne('--stop-daemon', '--pid-file=%s' % tmpname)
+ fn = tempfile.mktemp()
+ with open(fn, 'wb') as tmp:
+ tmp.write(b'9999999')
+ tmp.close()
+ inst = self._makeOne('--stop-daemon', '--pid-file=%s' % fn)
inst.run()
- try:
- tmp.close()
- except:
- pass
self.assertEqual(self.out_.getvalue(),
- 'PID in %s is not valid (deleting)' % tmpname)
+ 'PID in %s is not valid (deleting)' % fn)
def test_parse_vars_good(self):
vars = ['a=1', 'b=2']
@@ -81,7 +77,6 @@ class TestLazyWriter(unittest.TestCase):
return LazyWriter(filename, mode)
def test_open(self):
- import tempfile
filename = tempfile.mktemp()
try:
inst = self._makeOne(filename)
@@ -92,7 +87,6 @@ class TestLazyWriter(unittest.TestCase):
os.remove(filename)
def test_write(self):
- import tempfile
filename = tempfile.mktemp()
try:
inst = self._makeOne(filename)
@@ -105,7 +99,6 @@ class TestLazyWriter(unittest.TestCase):
os.remove(filename)
def test_writeline(self):
- import tempfile
filename = tempfile.mktemp()
try:
inst = self._makeOne(filename)
@@ -118,7 +111,6 @@ class TestLazyWriter(unittest.TestCase):
os.remove(filename)
def test_flush(self):
- import tempfile
filename = tempfile.mktemp()
try:
inst = self._makeOne(filename)