diff options
| -rw-r--r-- | pyramid/scaffolds/copydir.py | 15 | ||||
| -rw-r--r-- | pyramid/scripts/pserve.py | 2 | ||||
| -rw-r--r-- | pyramid/tests/test_authentication.py | 1 | ||||
| -rw-r--r-- | pyramid/tests/test_router.py | 2 | ||||
| -rw-r--r-- | pyramid/util.py | 2 |
5 files changed, 9 insertions, 13 deletions
diff --git a/pyramid/scaffolds/copydir.py b/pyramid/scaffolds/copydir.py index 4471777f2..0914bb0d4 100644 --- a/pyramid/scaffolds/copydir.py +++ b/pyramid/scaffolds/copydir.py @@ -106,9 +106,8 @@ def copy_dir(source, dest, vars, verbosity, simulate, indent=0, elif use_pkg_resources: content = pkg_resources.resource_string(source[0], full) else: - f = open(full, 'rb') - content = f.read() - f.close() + with open(full, 'rb') as f: + content = f.read() if sub_file: try: content = substitute_content( @@ -121,9 +120,8 @@ def copy_dir(source, dest, vars, verbosity, simulate, indent=0, continue # pragma: no cover already_exists = os.path.exists(dest_full) if already_exists: - f = open(dest_full, 'rb') - old_content = f.read() - f.close() + with open(dest_full, 'rb') as f: + old_content = f.read() if old_content == content: if verbosity: out('%s%s already exists (same content)' % @@ -144,9 +142,8 @@ def copy_dir(source, dest, vars, verbosity, simulate, indent=0, '%sCopying %s to %s' % (pad, os.path.basename(full), dest_full)) if not simulate: - f = open(dest_full, 'wb') - f.write(content) - f.close() + with open(dest_full, 'wb') as f: + f.write(content) def should_skip_file(name): """ diff --git a/pyramid/scripts/pserve.py b/pyramid/scripts/pserve.py index 094a811a4..1bfedf384 100644 --- a/pyramid/scripts/pserve.py +++ b/pyramid/scripts/pserve.py @@ -243,7 +243,7 @@ class PServeCommand(object): self._warn_daemon_deprecated() return self.show_status() - if cmd == 'restart' or cmd == 'stop': + if cmd in ('restart', 'stop'): self._warn_daemon_deprecated() result = self.stop_daemon() if result: diff --git a/pyramid/tests/test_authentication.py b/pyramid/tests/test_authentication.py index c7fc1c211..f1308f89e 100644 --- a/pyramid/tests/test_authentication.py +++ b/pyramid/tests/test_authentication.py @@ -1233,7 +1233,6 @@ class Test_parse_ticket(unittest.TestCase): 'cd7a2fa4910000000auserid!') result = self._callFUT('secret', ticket, '2001:db8::1', 'sha256') self.assertEqual(result, (10, 'userid', [''], '')) - pass class TestSessionAuthenticationPolicy(unittest.TestCase): def _getTargetClass(self): diff --git a/pyramid/tests/test_router.py b/pyramid/tests/test_router.py index b57c248d5..1cdc4abaa 100644 --- a/pyramid/tests/test_router.py +++ b/pyramid/tests/test_router.py @@ -1284,7 +1284,7 @@ class DummyView: def __call__(self, context, request): self.context = context self.request = request - if not self.raise_exception is None: + if self.raise_exception is not None: raise self.raise_exception return self.response diff --git a/pyramid/util.py b/pyramid/util.py index 5e43383b7..8fcd84f07 100644 --- a/pyramid/util.py +++ b/pyramid/util.py @@ -30,7 +30,7 @@ from pyramid.path import DottedNameResolver as _DottedNameResolver class DottedNameResolver(_DottedNameResolver): def __init__(self, package=None): # default to package = None for bw compat - return _DottedNameResolver.__init__(self, package) + _DottedNameResolver.__init__(self, package) _marker = object() |
