Skip to content

Commit

Permalink
Run flake8 w/ 'E4', fix imports/unused vars
Browse files Browse the repository at this point in the history
  • Loading branch information
bitprophet committed Aug 22, 2016
1 parent be06270 commit 4a62ffc
Show file tree
Hide file tree
Showing 15 changed files with 23 additions and 27 deletions.
2 changes: 1 addition & 1 deletion fabfile.py
Expand Up @@ -6,7 +6,7 @@

import nose

from fabric.api import abort, local, task
from fabric.api import task


@task(default=True)
Expand Down
1 change: 1 addition & 0 deletions fabric/api.py
Expand Up @@ -6,6 +6,7 @@
setup.py -- without triggering loads of most of the code. Which doesn't work so
well when you're using setup.py to install e.g. ssh!
"""

from fabric.context_managers import (cd, hide, settings, show, path, prefix,
lcd, quiet, warn_only, remote_tunnel, shell_env)
from fabric.decorators import (hosts, roles, runs_once, with_settings, task,
Expand Down
2 changes: 1 addition & 1 deletion fabric/context_managers.py
Expand Up @@ -539,7 +539,7 @@ def accept(channel, (src_addr, src_port), (dest_addr, dest_port)):

try:
sock.connect((local_host, local_port))
except Exception, e:
except Exception:
print "[%s] rtunnel: cannot connect to %s:%d (from local)" % (env.host_string, local_host, local_port)
channel.close()
return
Expand Down
2 changes: 1 addition & 1 deletion fabric/contrib/files.py
Expand Up @@ -10,7 +10,7 @@
from StringIO import StringIO
from functools import partial

from fabric.api import *
from fabric.api import run, sudo, hide, settings, env, put, abort
from fabric.utils import apply_lcwd


Expand Down
4 changes: 2 additions & 2 deletions fabric/state.py
Expand Up @@ -46,8 +46,8 @@ def _get_system_username():
except ImportError:
if win32:
import win32api
import win32security
import win32profile
import win32security # noqa
import win32profile # noqa
username = win32api.GetUserName()
return username

Expand Down
2 changes: 0 additions & 2 deletions integration/test_contrib.py
@@ -1,7 +1,5 @@
import os
import types
import re
import sys

from fabric.api import run, local
from fabric.contrib import files, project
Expand Down
6 changes: 3 additions & 3 deletions integration/test_operations.py
Expand Up @@ -6,7 +6,7 @@
import shutil

from fabric.api import (
run, path, put, sudo, abort, warn_only, env, cd, local, settings, get
run, path, put, sudo, env, cd, local, settings, get
)
from fabric.contrib.files import exists

Expand Down Expand Up @@ -143,7 +143,7 @@ def test_get_with_use_sudo_unowned_file(self):
sudo("chmod 0440 %s" % target)
# Pull down with use_sudo, confirm contents
local_ = StringIO()
result = get(
get(
local_path=local_,
remote_path=target,
use_sudo=True,
Expand All @@ -165,7 +165,7 @@ def test_get_with_use_sudo_groupowned_file(self):
sudo("chmod 0640 %s" % target)
# Do eet
local_ = StringIO()
result = get(
get(
local_path=local_,
remote_path=target,
use_sudo=True,
Expand Down
2 changes: 0 additions & 2 deletions integration/utils.py
Expand Up @@ -4,8 +4,6 @@
# Pull in regular tests' utilities
mod = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'tests'))
sys.path.insert(0, mod)
from mock_streams import mock_streams
#from utils import FabricTest
# Clean up
del sys.path[0]

Expand Down
2 changes: 2 additions & 0 deletions setup.cfg
@@ -0,0 +1,2 @@
[flake8]
exclude = tests/support,tests/Python26SocketServer.py,sites,fabric/api.py
2 changes: 1 addition & 1 deletion tests/mock_streams.py
Expand Up @@ -71,7 +71,7 @@ def inner_wrapper(*args, **kwargs):
if stderr:
my_stderr, sys.stderr = sys.stderr, fake_stderr
try:
ret = func(*args, **kwargs)
func(*args, **kwargs)
finally:
if stdout:
sys.stdout = my_stdout
Expand Down
2 changes: 0 additions & 2 deletions tests/test_main.py
Expand Up @@ -494,7 +494,6 @@ def test_class_based_tasks_are_found_with_proper_name(self):
Wrapped new-style tasks should preserve their function names
"""
module = fabfile('decorated_fabfile_with_classbased_task.py')
from fabric.state import env
with path_prefix(module):
docs, funcs = load_fabfile(module)
eq_(len(funcs), 1)
Expand All @@ -506,7 +505,6 @@ def test_class_based_tasks_are_found_with_variable_name(self):
variable name.
"""
module = fabfile('classbased_task_fabfile.py')
from fabric.state import env
with path_prefix(module):
docs, funcs = load_fabfile(module)
eq_(len(funcs), 1)
Expand Down
1 change: 0 additions & 1 deletion tests/test_operations.py
Expand Up @@ -22,7 +22,6 @@
from fabric.exceptions import CommandTimeout

from fabric.sftp import SFTP
from fabric.context_managers import settings
from fabric.decorators import with_settings
from utils import (eq_, aborts, assert_contains, eq_contents,
with_patched_input, FabricTest)
Expand Down
3 changes: 2 additions & 1 deletion tests/test_server.py
Expand Up @@ -6,14 +6,15 @@
no need to pollute Fab's own test suite. (Yes, if these tests fail, it's likely
that the Fabric tests using the test server may also have issues, but still.)
"""
__test__ = False

from nose.tools import eq_, ok_

from fabric.network import ssh

from server import FakeSFTPServer

__test__ = False


class AttrHolder(object):
pass
Expand Down
10 changes: 5 additions & 5 deletions tests/test_tasks.py
Expand Up @@ -2,7 +2,7 @@

from fudge import Fake, patched_context, with_fakes
import unittest
from nose.tools import eq_, raises, ok_
from nose.tools import raises, ok_
import random
import sys

Expand Down Expand Up @@ -31,7 +31,7 @@ def test_passes_unused_args_to_parent(self):

def foo(): pass
try:
task = WrappedCallableTask(foo, *args)
WrappedCallableTask(foo, *args)
except TypeError:
msg = "__init__ raised a TypeError, meaning args weren't handled"
self.fail(msg)
Expand All @@ -42,20 +42,20 @@ def test_passes_unused_kwargs_to_parent(self):

def foo(): pass
try:
task = WrappedCallableTask(foo, **kwargs)
WrappedCallableTask(foo, **kwargs)
except TypeError:
self.fail(
"__init__ raised a TypeError, meaning kwargs weren't handled")

def test_allows_any_number_of_args(self):
args = [i for i in range(random.randint(0, 10))]
def foo(): pass
task = WrappedCallableTask(foo, *args)
WrappedCallableTask(foo, *args)

def test_allows_any_number_of_kwargs(self):
kwargs = dict([("key%d" % i, i) for i in range(random.randint(0, 10))])
def foo(): pass
task = WrappedCallableTask(foo, **kwargs)
WrappedCallableTask(foo, **kwargs)

def test_run_is_wrapped_callable(self):
def foo(): pass
Expand Down
9 changes: 4 additions & 5 deletions tests/test_utils.py
Expand Up @@ -28,19 +28,19 @@ def test_warn():


def test_indent():
for description, input, output in (
for description, input_, output_ in (
("Sanity check: 1 line string",
'Test', ' Test'),
("List of strings turns in to strings joined by \\n",
["Test", "Test"], ' Test\n Test'),
):
eq_.description = "indent(): %s" % description
yield eq_, indent(input), output
yield eq_, indent(input_), output_
del eq_.description


def test_indent_with_strip():
for description, input, output in (
for description, input_ output_ in (
("Sanity check: 1 line string",
indent('Test', strip=True), ' Test'),
("Check list of strings",
Expand All @@ -50,7 +50,7 @@ def test_indent_with_strip():
' Test\n Test'),
):
eq_.description = "indent(strip=True): %s" % description
yield eq_, input, output
yield eq_, input_ output_
del eq_.description


Expand Down Expand Up @@ -171,7 +171,6 @@ def test_puts_without_prefix():
puts() shouldn't prefix output with env.host_string if show_prefix is False
"""
s = "my output"
h = "localhost"
puts(s, show_prefix=False)
eq_(sys.stdout.getvalue(), "%s" % (s + "\n"))

Expand Down

0 comments on commit 4a62ffc

Please sign in to comment.