Skip to content

Commit

Permalink
pragma: no cover for some error cases in test_ftpserver.py
Browse files Browse the repository at this point in the history
  • Loading branch information
jamadden committed Oct 26, 2017
1 parent 94596f7 commit 7db21e6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 18 deletions.
13 changes: 2 additions & 11 deletions src/zope/server/ftp/tests/test_demofs.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
##############################################################################
"""Test the Demo Filesystem implementation.
"""
from unittest import TestCase, TestSuite, main, makeSuite
import unittest
from io import BytesIO

from . import demofs
from .fstests import FileSystemTests


class Test(FileSystemTests, TestCase):
class Test(FileSystemTests, unittest.TestCase):

def setUp(self):
root = demofs.Directory()
Expand All @@ -30,12 +30,3 @@ def setUp(self):
fs.writefile(self.file_name, BytesIO(self.file_contents))
fs.writefile(self.unwritable_filename, BytesIO(b"save this"))
fs.get(self.unwritable_filename).revoke('bob', demofs.write)


def test_suite():
return TestSuite((
makeSuite(Test),
))

if __name__=='__main__':
main(defaultTest='test_suite')
14 changes: 7 additions & 7 deletions src/zope/server/ftp/tests/test_ftpserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def setUp(self):
if len(asyncore.socket_map) != 1:
# Let sockets die off.
# TODO tests should be more careful to clear the socket map.
asyncore.poll(0.1)
asyncore.poll(0.1) # pragma: no cover
self.orig_map_size = len(asyncore.socket_map)

root_dir = demofs.Directory()
Expand All @@ -81,7 +81,7 @@ def setUp(self):
task_dispatcher=td, adj=my_adj)
if CONNECT_TO_PORT == 0:
self.port = self.server.socket.getsockname()[1]
else:
else: # pragma: no cover
self.port = CONNECT_TO_PORT
self.run_loop = 1
self.counter = 0
Expand All @@ -103,10 +103,10 @@ def tearDown(self):
if len(asyncore.socket_map) == self.orig_map_size:
# Clean!
break
if time.time() >= timeout:
if time.time() >= timeout: # pragma: no cover
self.fail('Leaked a socket: %s' % repr(asyncore.socket_map))
break
asyncore.poll(0.1)
asyncore.poll(0.1) # pragma: no cover

super(Tests, self).tearDown()

Expand All @@ -121,7 +121,7 @@ def loop(self):
try:
asyncore.poll(0.1)
continue
except select.error as data:
except select.error as data: # pragma: no cover
print("EXCEPTION POLLING IN LOOP(): %s" % data)
if data.args[0] == EBADF:
for key in asyncore.socket_map:
Expand All @@ -138,10 +138,10 @@ def loop(self):
print(asyncore.socket_map[key])
print(asyncore.socket_map[key].__class__)
print("")
except:
except: # pragma: no cover pylint:disable=bare-except
print("WEIRD EXCEPTION IN LOOP")
traceback.print_exception(*(sys.exc_info()+(100,)))
print("")
print("") # pragma: no cover

def getFTPConnection(self, login=1):
# import only now to prevent the testrunner from importing it too early
Expand Down

0 comments on commit 7db21e6

Please sign in to comment.